Documentation ¶
Index ¶
- Constants
- type Config
- type Core
- func (c *Core) BatchRequested(batch flow.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 flow.Range)
- func (c *Core) RequestBlock(blockID flow.Identifier)
- func (c *Core) RequestHeight(height uint64)
- func (c *Core) ScanPending(final *flow.Header) ([]flow.Range, []flow.Batch)
- func (c *Core) WithinTolerance(final *flow.Header, height uint64) bool
- type Status
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 )
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, 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)
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.
type Status ¶
type Status struct { Queued time.Time // when we originally queued this block request Requested time.Time // the last time we requested this block Attempts uint // how many times we've requested this block Header *flow.Header // the requested header, if we've received it Received time.Time // when we received a response }
Status keeps track of a block download status.
func NewQueuedStatus ¶
func NewQueuedStatus() *Status