chainsync

package
v0.33.18-fix-throttle Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
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 New

func New(log zerolog.Logger, config Config, metrics module.ChainSyncMetrics, chainID flow.ChainID) (*Core, error)

func (*Core) BatchRequested

func (c *Core) BatchRequested(batch chainsync.Batch)

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

func (c *Core) HandleBlock(header *flow.Header) bool

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

func (c *Core) HandleHeight(final *flow.Header, height uint64)

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) Prune

func (c *Core) Prune(final *flow.Header)

func (*Core) RangeRequested

func (c *Core) RangeRequested(ran chainsync.Range)

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 (c *Core) RequestHeight(height uint64)

func (*Core) ScanPending

func (c *Core) ScanPending(final *flow.Header) ([]chainsync.Range, []chainsync.Batch)

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.

func (*Core) WithinTolerance

func (c *Core) WithinTolerance(final *flow.Header, height uint64) bool

WithinTolerance returns whether or not the given height is within configured height tolerance, wrt the given local finalized header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL