synchronization

package
v0.26.16-access-conn-pool Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

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) (*Core, error)

func (*Core) BatchRequested

func (c *Core) BatchRequested(batch flow.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, 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 flow.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)

func (*Core) RequestHeight

func (c *Core) RequestHeight(height uint64)

func (*Core) ScanPending

func (c *Core) ScanPending(final *flow.Header) ([]flow.Range, []flow.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.

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

func (*Status) StatusString added in v0.21.10

func (s *Status) StatusString() string

func (*Status) WasQueued

func (s *Status) WasQueued() bool

func (*Status) WasReceived

func (s *Status) WasReceived() bool

func (*Status) WasRequested

func (s *Status) WasRequested() bool

Jump to

Keyboard shortcuts

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