Documentation ¶
Index ¶
- Variables
- func FetchHistoryBlocks(ctx context.Context, logInfo func(s string, args ...interface{}), ...) (int64, error)
- func GetDatanodeClientFromIPAndPort(ip string, port int) (v2.TradingDataServiceClient, *grpc.ClientConn, error)
- func GetMostRecentHistorySegmentFromPeer(ctx context.Context, ip string, datanodeGrpcAPIPort int) (*v2.GetMostRecentNetworkHistorySegmentResponse, error)
- func InitialiseDatanodeFromNetworkHistory(parentCtx context.Context, cfg InitializationConfig, log *logging.Logger, ...) error
- func KillAllConnectionsToDatabase(ctx context.Context, connConfig sqlstore.ConnectionConfig) error
- func VerifyChainID(chainID string, chainService *service.Chain) error
- type BlockCommitHandler
- type Config
- type ContiguousHistory
- func GetContiguousHistories[T Segment](historySegments []T) []*ContiguousHistory
- func GetContiguousHistory[T Segment](segments []T, fromHeight int64, toHeight int64) (*ContiguousHistory, error)
- func GetContiguousHistoryForSpan(contiguousHistories []*ContiguousHistory, fromHeight int64, toHeight int64) *ContiguousHistory
- func GetMostRecentContiguousHistory[T Segment](historySegments []T) *ContiguousHistory
- type FetchResult
- type InitializationConfig
- type NetworkHistory
- type PeerResponse
- func GetMostRecentHistorySegmentFromPeersAddresses(ctx context.Context, peerAddresses []string, swarmKeySeed string, ...) (*PeerResponse, map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, ...)
- func SelectMostRecentHistorySegmentResponse(peerToResponse map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, ...) *PeerResponse
- type ProtocolUpgradeHandler
- type Segment
- type Service
- func (d *Service) CopyHistorySegmentToFile(ctx context.Context, historySegmentID string, outFile string) error
- func (d *Service) CreateAndPublishSegment(ctx context.Context, chainID string, toHeight int64) error
- func (d *Service) FetchHistorySegment(ctx context.Context, historySegmentID string) (Segment, error)
- func (d *Service) GetActivePeerIPAddresses() []string
- func (d *Service) GetBootstrapPeers() []string
- func (d *Service) GetConnectedPeerAddresses() ([]string, error)
- func (d *Service) GetDatanodeBlockSpan(ctx context.Context) (sqlstore.DatanodeBlockSpan, error)
- func (d *Service) GetHighestBlockHeightHistorySegment() (Segment, error)
- func (d *Service) GetIpfsAddress() (string, error)
- func (d *Service) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int) (*PeerResponse, map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, ...)
- func (d *Service) GetSwarmKey() string
- func (d *Service) GetSwarmKeySeed() string
- func (d *Service) ListAllHistorySegments() ([]Segment, error)
- func (d *Service) LoadNetworkHistoryIntoDatanode(ctx context.Context, contiguousHistory ContiguousHistory, ...) (snapshot.LoadResult, error)
- func (d *Service) LoadNetworkHistoryIntoDatanodeWithLog(ctx context.Context, loadLog snapshot.LoadLog, ...) (snapshot.LoadResult, error)
- func (d *Service) Stop()
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrChainNotFound = errors.New("no chain found")
Functions ¶
func FetchHistoryBlocks ¶
func FetchHistoryBlocks(ctx context.Context, logInfo func(s string, args ...interface{}), historySegmentID string, fetchHistory func(ctx context.Context, historySegmentID string) (FetchResult, error), numBlocksToFetch int64, ) (int64, error)
FetchHistoryBlocks will keep fetching history until numBlocksToFetch is reached or all history is retrieved.
func GetDatanodeClientFromIPAndPort ¶
func GetDatanodeClientFromIPAndPort(ip string, port int) (v2.TradingDataServiceClient, *grpc.ClientConn, error)
func InitialiseDatanodeFromNetworkHistory ¶
func InitialiseDatanodeFromNetworkHistory(parentCtx context.Context, cfg InitializationConfig, log *logging.Logger, connCfg sqlstore.ConnectionConfig, networkHistoryService NetworkHistory, grpcPorts []int, verboseMigration bool, ) error
func KillAllConnectionsToDatabase ¶
func KillAllConnectionsToDatabase(ctx context.Context, connConfig sqlstore.ConnectionConfig) error
Types ¶
type BlockCommitHandler ¶
type BlockCommitHandler struct {
// contains filtered or unexported fields
}
func NewBlockCommitHandler ¶
func (*BlockCommitHandler) OnBlockCommitted ¶
type Config ¶
type Config struct { Level encoding.LogLevel `long:"log-level"` Enabled encoding.Bool `long:"enabled" description:"set to false to disable network history"` WipeOnStartup encoding.Bool `long:"wipe-on-startup" description:"remove all network history state on startup"` Publish encoding.Bool `long:"publish" description:"if true this node will create and publish network history segments"` Store store.Config `group:"Store" namespace:"store"` Snapshot snapshot.Config `group:"Snapshot" namespace:"snapshot"` Initialise InitializationConfig `group:"Initialise" namespace:"initialise"` }
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
type ContiguousHistory ¶ added in v0.68.0
func GetContiguousHistories ¶ added in v0.68.0
func GetContiguousHistories[T Segment](historySegments []T) []*ContiguousHistory
func GetContiguousHistory ¶ added in v0.68.0
func GetContiguousHistory[T Segment](segments []T, fromHeight int64, toHeight int64) (*ContiguousHistory, error)
GetContiguousHistory returns the contiguous history for the given block span, oldest first.
func GetContiguousHistoryForSpan ¶ added in v0.68.0
func GetContiguousHistoryForSpan(contiguousHistories []*ContiguousHistory, fromHeight int64, toHeight int64) *ContiguousHistory
func GetMostRecentContiguousHistory ¶ added in v0.68.0
func GetMostRecentContiguousHistory[T Segment](historySegments []T) *ContiguousHistory
type FetchResult ¶
func FromSegmentIndexEntry ¶
func FromSegmentIndexEntry(s Segment) FetchResult
type InitializationConfig ¶
type InitializationConfig struct { ToSegment string `` /* 146-byte string literal not displayed */ MinimumBlockCount int64 `long:"block-count" description:"the minimum number of blocks to fetch"` TimeOut encoding.Duration `long:"timeout" description:"maximum time allowed to auto-initialise the node"` GrpcAPIPorts []int `long:"grpc-api-ports" description:"list of additional ports to check to for api connection when getting latest segment"` FetchRetryMax uint64 `long:"fetch-retry-max" description:"maximum number of times to retry fetching segments - default 5"` RetryTimeout encoding.Duration `long:"retry-timeout" description:"time to wait between retries - default 1 second"` }
func NewDefaultInitializationConfig ¶
func NewDefaultInitializationConfig() InitializationConfig
type NetworkHistory ¶
type NetworkHistory interface { FetchHistorySegment(ctx context.Context, historySegmentID string) (Segment, error) LoadNetworkHistoryIntoDatanode(ctx context.Context, contiguousHistory ContiguousHistory, cfg sqlstore.ConnectionConfig, withIndexesAndOrderTriggers, verbose bool) (snapshot.LoadResult, error) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int) (*PeerResponse, map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, error) GetDatanodeBlockSpan(ctx context.Context) (sqlstore.DatanodeBlockSpan, error) ListAllHistorySegments() ([]Segment, error) }
type PeerResponse ¶
type PeerResponse struct { PeerAddr string Response *v2.GetMostRecentNetworkHistorySegmentResponse }
func GetMostRecentHistorySegmentFromPeersAddresses ¶
func GetMostRecentHistorySegmentFromPeersAddresses(ctx context.Context, peerAddresses []string, swarmKeySeed string, grpcAPIPorts []int, ) (*PeerResponse, map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, error)
func SelectMostRecentHistorySegmentResponse ¶
func SelectMostRecentHistorySegmentResponse(peerToResponse map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, swarmKeySeed string) *PeerResponse
TODO this needs some thought as to the best strategy to select the response to avoid spoofing.
type ProtocolUpgradeHandler ¶
type ProtocolUpgradeHandler struct {
// contains filtered or unexported fields
}
func NewProtocolUpgradeHandler ¶
func NewProtocolUpgradeHandler( log *logging.Logger, protocolUpgradeService *service.ProtocolUpgrade, eventSender eventSender, createAndPublishSegment func(ctx context.Context, chainID string, toHeight int64) error, ) *ProtocolUpgradeHandler
func (*ProtocolUpgradeHandler) GetProtocolUpgradeStarted ¶
func (t *ProtocolUpgradeHandler) GetProtocolUpgradeStarted() bool
func (*ProtocolUpgradeHandler) OnProtocolUpgradeEvent ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewWithStore ¶
func (*Service) CopyHistorySegmentToFile ¶
func (*Service) CreateAndPublishSegment ¶
func (*Service) FetchHistorySegment ¶
func (*Service) GetActivePeerIPAddresses ¶ added in v0.68.0
func (*Service) GetBootstrapPeers ¶ added in v0.68.0
func (*Service) GetConnectedPeerAddresses ¶ added in v0.68.0
func (*Service) GetDatanodeBlockSpan ¶
func (*Service) GetHighestBlockHeightHistorySegment ¶
func (*Service) GetIpfsAddress ¶ added in v0.68.0
func (*Service) GetMostRecentHistorySegmentFromPeers ¶
func (d *Service) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int, ) (*PeerResponse, map[string]*v2.GetMostRecentNetworkHistorySegmentResponse, error)
func (*Service) GetSwarmKey ¶
func (*Service) GetSwarmKeySeed ¶ added in v0.68.0
func (*Service) ListAllHistorySegments ¶
func (*Service) LoadNetworkHistoryIntoDatanode ¶
func (d *Service) LoadNetworkHistoryIntoDatanode(ctx context.Context, contiguousHistory ContiguousHistory, connConfig sqlstore.ConnectionConfig, withIndexesAndOrderTriggers, verbose bool, ) (snapshot.LoadResult, error)
func (*Service) LoadNetworkHistoryIntoDatanodeWithLog ¶ added in v0.68.0
func (d *Service) LoadNetworkHistoryIntoDatanodeWithLog(ctx context.Context, loadLog snapshot.LoadLog, contiguousHistory ContiguousHistory, connConfig sqlstore.ConnectionConfig, withIndexesAndOrderTriggers, verbose bool, ) (snapshot.LoadResult, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.