Documentation ¶
Index ¶
- type Logger
- type PruneHelper
- type StatefulSyncer
- func (s *StatefulSyncer) Block(ctx context.Context, network *types.NetworkIdentifier, ...) (*types.Block, error)
- func (s *StatefulSyncer) BlockAdded(ctx context.Context, block *types.Block) error
- func (s *StatefulSyncer) BlockRemoved(ctx context.Context, blockIdentifier *types.BlockIdentifier) error
- func (s *StatefulSyncer) NetworkStatus(ctx context.Context, network *types.NetworkIdentifier) (*types.NetworkStatusResponse, error)
- func (s *StatefulSyncer) Prune(ctx context.Context, helper PruneHelper) error
- func (s *StatefulSyncer) Sync(ctx context.Context, startIndex int64, endIndex int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface { AddBlockStream(context.Context, *types.Block) error RemoveBlockStream(context.Context, *types.BlockIdentifier) error }
Logger is used by the statefulsyncer to log the addition and removal of blocks.
type PruneHelper ¶
type PruneHelper interface { // PruneableIndex is the largest block // index that is considered safe to prune. PruneableIndex(ctx context.Context, headIndex int64) (int64, error) }
PruneHelper is used by the stateful syncer to determine the safe pruneable index. This is a helper instead of a static argument because the pruneable index is often a function of the state of some number of structs.
type StatefulSyncer ¶
type StatefulSyncer struct {
// contains filtered or unexported fields
}
StatefulSyncer is an abstraction layer over the stateless syncer package. This layer handles sync restarts and provides fully populated blocks during reorgs (not provided by stateless syncer).
func New ¶
func New( ctx context.Context, network *types.NetworkIdentifier, fetcher *fetcher.Fetcher, blockStorage *storage.BlockStorage, counterStorage *storage.CounterStorage, logger Logger, cancel context.CancelFunc, workers []storage.BlockWorker, cacheSize int, maxConcurrency int64, pastBlockLimit int, ) *StatefulSyncer
New returns a new *StatefulSyncer.
func (*StatefulSyncer) Block ¶
func (s *StatefulSyncer) Block( ctx context.Context, network *types.NetworkIdentifier, block *types.PartialBlockIdentifier, ) (*types.Block, error)
Block is called by the syncer to fetch a block.
func (*StatefulSyncer) BlockAdded ¶
BlockAdded is called by the syncer when a block is added.
func (*StatefulSyncer) BlockRemoved ¶
func (s *StatefulSyncer) BlockRemoved( ctx context.Context, blockIdentifier *types.BlockIdentifier, ) error
BlockRemoved is called by the syncer when a block is removed.
func (*StatefulSyncer) NetworkStatus ¶
func (s *StatefulSyncer) NetworkStatus( ctx context.Context, network *types.NetworkIdentifier, ) (*types.NetworkStatusResponse, error)
NetworkStatus is called by the syncer to get the current network status.
func (*StatefulSyncer) Prune ¶
func (s *StatefulSyncer) Prune(ctx context.Context, helper PruneHelper) error
Prune will repeatedly attempt to prune BlockStorage until the context is canceled or an error is encountered.
PruneHelper is provided as an argument here instead of in the initializer because the caller may wish to change pruning strategies during syncing.