Documentation
¶
Index ¶
Constants ¶
View Source
const ( // PastBlockSize is the maximum number of previously // processed blocks we keep in the syncer to handle // reorgs correctly. If there is a reorg greater than // PastBlockSize, it will not be handled correctly. // // TODO: make configurable PastBlockSize = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface {
BlockAdded(
ctx context.Context,
block *types.Block,
) error
BlockRemoved(
ctx context.Context,
block *types.BlockIdentifier,
) error
}
Handler is called at various times during the sync cycle to handle different events. It is common to write logs or perform reconciliation in the sync processor.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer coordinates blockchain syncing without relying on a storage interface. Instead, it calls a provided Handler whenever a block is added or removed. This provides the client the opportunity to define the logic used to handle each new block. In the rosetta-cli, we handle reconciliation, state storage, and logging in the handler.
func New ¶
func New( network *types.NetworkIdentifier, fetcher *fetcher.Fetcher, handler Handler, cancel context.CancelFunc, pastBlocks []*types.BlockIdentifier, ) *Syncer
New creates a new Syncer. If pastBlocks is left nil, it will be set to an empty slice.
Click to show internal directories.
Click to hide internal directories.