Documentation ¶
Index ¶
- Constants
- type Config
- type Core
- func (c *Core) BatchRequested(batch chainsync.Batch)
- func (c *Core) HandleBlock(header *flow.Header) bool
- func (c *Core) HandleHeight(final *flow.Header, height uint64)
- func (c *Core) Prune(final *flow.Header)
- func (c *Core) RangeRequested(ran chainsync.Range)
- func (c *Core) RequestBlock(blockID flow.Identifier, height uint64)
- func (c *Core) RequestHeight(height uint64)
- func (c *Core) ScanPending(final *flow.Header) ([]chainsync.Range, []chainsync.Batch)
- func (c *Core) WithinTolerance(final *flow.Header, height uint64) bool
Constants ¶
const ( // DefaultPollNodes is the default number of nodes we send a message to on // each poll interval. DefaultPollNodes uint = 3 // DefaultBlockRequestNodes is the default number of nodes we request a // block resource from. DefaultBlockRequestNodes uint = 3 // DefaultQueuedHeightMultiplicity limits the number of heights we queue // above the current finalized height. DefaultQueuedHeightMultiplicity uint = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { RetryInterval time.Duration // the initial interval before we retry a request, uses exponential backoff Tolerance uint // determines how big of a difference in block heights we tolerated before actively syncing with range requests MaxAttempts uint // the maximum number of attempts we make for each requested block/height before discarding MaxSize uint // the maximum number of blocks we request in the same block request message MaxRequests uint // the maximum number of requests we send during each scanning period }
func DefaultConfig ¶
func DefaultConfig() Config
type Core ¶
type Core struct { Config Config // contains filtered or unexported fields }
Core contains core logic, configuration, and state for chain state synchronization. It is generic to chain type, so it works for both consensus and collection nodes.
Core should be wrapped by a type-aware engine that manages the specifics of each chain. Example: https://github.com/onflow/flow-go/blob/master/engine/common/synchronization/engine.go
Core is safe for concurrent use by multiple goroutines.
func (*Core) BatchRequested ¶
BatchRequested updates status state for a batch of block IDs that has been successfully requested. Must be called when a batch request is submitted.
func (*Core) HandleBlock ¶
HandleBlock handles receiving a new block from another node. It returns true if the block should be processed by the compliance layer and false if it should be ignored.
func (*Core) HandleHeight ¶
HandleHeight handles receiving a new highest finalized height from another node. If the height difference between local and the reported height is outside tolerance, we do nothing. Otherwise, we queue each missing height.
func (*Core) RangeRequested ¶
RangeRequested updates status state for a range of block heights that has been successfully requested. Must be called when a range request is submitted.
func (*Core) RequestBlock ¶
func (c *Core) RequestBlock(blockID flow.Identifier, height uint64)
func (*Core) RequestHeight ¶
func (*Core) ScanPending ¶
ScanPending scans all pending block statuses for blocks that should be requested. It apportions requestable items into range and batch requests according to configured maximums, giving precedence to range requests.