Documentation ¶
Index ¶
- Variables
- func DatanodeFromDeHistory(parentCtx context.Context, cfg InitializationConfig, log *logging.Logger, ...) error
- 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.HistorySegment, error)
- func GetMostRecentHistorySegmentFromPeerAddresses(ctx context.Context, activePeerAddresses []string, grpcAPIPorts []int) (*v2.HistorySegment, map[string]*v2.HistorySegment, error)
- func SelectRootSegment(peerToSegment map[string]*v2.HistorySegment) *v2.HistorySegment
- func VerifyChainID(chainID string, chainService *service.Chain) error
- type BlockCommitHandler
- type Config
- type DeHistory
- type FetchResult
- type InitializationConfig
- type ProtocolUpgradeHandler
- 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) (store.SegmentIndexEntry, error)
- func (d *Service) GetActivePeerAddresses() []string
- func (d *Service) GetContiguousHistory() ([]aggregation.AggregatedHistorySegment, error)
- func (d *Service) GetHighestBlockHeightHistorySegment() (store.SegmentIndexEntry, error)
- func (d *Service) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int) (*v2.HistorySegment, map[string]*v2.HistorySegment, error)
- func (d *Service) ListAllHistorySegments() ([]store.SegmentIndexEntry, error)
- func (d *Service) LoadAllAvailableHistoryIntoDatanode(ctx context.Context, sqlFs fs.FS) (snapshot.LoadResult, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrChainNotFound = errors.New("no chain found")
View Source
var ErrDeHistoryNotAvailable = errors.New("no decentralized history is available")
View Source
var ErrNoActivePeersFound = errors.New("no active peers found")
Functions ¶
func DatanodeFromDeHistory ¶ added in v0.64.0
func DatanodeFromDeHistory(parentCtx context.Context, cfg InitializationConfig, log *logging.Logger, deHistoryService DeHistory, currentSpan sqlstore.DatanodeBlockSpan, grpcPorts []int, ) error
func FetchHistoryBlocks ¶ added in v0.64.0
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 ¶ added in v0.64.0
func GetDatanodeClientFromIPAndPort(ip string, port int) (v2.TradingDataServiceClient, *grpc.ClientConn, error)
func GetMostRecentHistorySegmentFromPeer ¶ added in v0.64.0
func GetMostRecentHistorySegmentFromPeerAddresses ¶ added in v0.64.0
func GetMostRecentHistorySegmentFromPeerAddresses(ctx context.Context, activePeerAddresses []string, grpcAPIPorts []int, ) (*v2.HistorySegment, map[string]*v2.HistorySegment, error)
func SelectRootSegment ¶ added in v0.64.0
func SelectRootSegment(peerToSegment map[string]*v2.HistorySegment) *v2.HistorySegment
TODO this needs some thought as to the best strategy to select the root segment to avoid spoofing.
Types ¶
type BlockCommitHandler ¶ added in v0.63.0
type BlockCommitHandler struct {
// contains filtered or unexported fields
}
func NewBlockCommitHandler ¶ added in v0.63.0
func NewBlockCommitHandler( log *logging.Logger, cfg Config, snapshotData func(ctx context.Context, chainID string, toHeight int64) error, getNetworkParameter func(ctx context.Context, key string) (entities.NetworkParameter, error), usingEventFile bool, eventFileTimeBetweenBlock time.Duration, ) *BlockCommitHandler
func (*BlockCommitHandler) OnBlockCommitted ¶ added in v0.63.0
func (b *BlockCommitHandler) OnBlockCommitted(ctx context.Context, chainID string, blockHeight int64)
type Config ¶
type Config struct { Level encoding.LogLevel `long:"log-level"` Enabled encoding.Bool `long:"enabled" description:"set to false to disable decentralized history"` WipeOnStartup encoding.Bool `long:"wipe-on-startup" description:"remove all deHistory state on startup"` Publish encoding.Bool `long:"publish" description:"if true this node will create and publish decentralized 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 DeHistory ¶ added in v0.64.0
type DeHistory interface { FetchHistorySegment(ctx context.Context, historySegmentID string) (store.SegmentIndexEntry, error) LoadAllAvailableHistoryIntoDatanode(ctx context.Context, sqlFs fs.FS) (snapshot.LoadResult, error) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int) (*v2.HistorySegment, map[string]*v2.HistorySegment, error) }
type FetchResult ¶ added in v0.64.0
func FromSegmentIndexEntry ¶ added in v0.64.0
func FromSegmentIndexEntry(s store.SegmentIndexEntry) FetchResult
type InitializationConfig ¶ added in v0.64.0
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"` }
func NewDefaultInitializationConfig ¶ added in v0.64.0
func NewDefaultInitializationConfig() InitializationConfig
type ProtocolUpgradeHandler ¶ added in v0.63.0
type ProtocolUpgradeHandler struct {
// contains filtered or unexported fields
}
func NewProtocolUpgradeHandler ¶ added in v0.63.0
func NewProtocolUpgradeHandler(log *logging.Logger, protocolUpgradeService *service.ProtocolUpgrade, createAndPublishSegment func(ctx context.Context, chainID string, toHeight int64) error, ) *ProtocolUpgradeHandler
func (*ProtocolUpgradeHandler) GetProtocolUpgradeStarted ¶ added in v0.63.0
func (t *ProtocolUpgradeHandler) GetProtocolUpgradeStarted() bool
func (*ProtocolUpgradeHandler) OnProtocolUpgradeEvent ¶ added in v0.63.0
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewWithStore ¶
func (*Service) CopyHistorySegmentToFile ¶ added in v0.62.0
func (*Service) CreateAndPublishSegment ¶ added in v0.63.0
func (*Service) FetchHistorySegment ¶
func (*Service) GetActivePeerAddresses ¶
func (*Service) GetContiguousHistory ¶
func (d *Service) GetContiguousHistory() ([]aggregation.AggregatedHistorySegment, error)
GetContiguousHistory returns all available contiguous (no gaps) history from the current datanode height, or if the datanode has no data it will return the contiguous history from the highest decentralized history segment.
func (*Service) GetHighestBlockHeightHistorySegment ¶
func (d *Service) GetHighestBlockHeightHistorySegment() (store.SegmentIndexEntry, error)
func (*Service) GetMostRecentHistorySegmentFromPeers ¶ added in v0.64.0
func (d *Service) GetMostRecentHistorySegmentFromPeers(ctx context.Context, grpcAPIPorts []int, ) (*v2.HistorySegment, map[string]*v2.HistorySegment, error)
func (*Service) ListAllHistorySegments ¶
func (d *Service) ListAllHistorySegments() ([]store.SegmentIndexEntry, error)
func (*Service) LoadAllAvailableHistoryIntoDatanode ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.