block_queue

package
v0.43.1-rc.1.access-me... Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingParent = fmt.Errorf("missing parent block")

Functions

This section is empty.

Types

type BlockQueue

type BlockQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BlockQueue keeps track of state of blocks and determines which blocks are executable A block becomes executable when all the following conditions are met: 1. the block has been validated by consensus algorithm 2. the block's parent has been executed 3. all the collections included in the block have been received

func NewBlockQueue

func NewBlockQueue(logger zerolog.Logger) *BlockQueue

func (*BlockQueue) GetMissingCollections

func (q *BlockQueue) GetMissingCollections(blockID flow.Identifier) (
	[]*MissingCollection,
	*flow.StateCommitment,
	error,
)

GetMissingCollections returns the missing collections and the start state for the given block Useful for debugging what is missing for the next unexecuted block to become executable. It returns an error if the block is not found or if could not construct missing collection.

func (*BlockQueue) HandleBlock

func (q *BlockQueue) HandleBlock(block *flow.Block, parentFinalState *flow.StateCommitment) (
	[]*MissingCollection,
	[]*entity.ExecutableBlock,
	error,
)

HandleBlock is called when a new block is received, the parentFinalState indicates whether its parent block has been executed. Caller must ensure: 1. blocks are passsed in order, i.e. parent block is passed in before its child block 2. if a block's parent is not executed, then the parent block must be passed in first 3. if a block's parent is executed, then the parent's finalState must be passed in It returns (nil, nil, nil) if this block is a duplication

func (*BlockQueue) HandleCollection

func (q *BlockQueue) HandleCollection(collection *flow.Collection) ([]*entity.ExecutableBlock, error)

HandleCollection is called when a new collection is received It returns a list of executable blocks that contains the collection

func (*BlockQueue) OnBlockExecuted

func (q *BlockQueue) OnBlockExecuted(
	blockID flow.Identifier,
	commit flow.StateCommitment,
) ([]*entity.ExecutableBlock, error)

OnBlockExecuted is called when a block is executed It returns a list of executable blocks (usually its child blocks) The caller has to ensure OnBlockExecuted is not called in a wrong order, such as OnBlockExecuted(childBlock) being called before OnBlockExecuted(parentBlock).

type MissingCollection

type MissingCollection struct {
	BlockID   flow.Identifier
	Height    uint64
	Guarantee *flow.CollectionGuarantee
}

MissingCollection stores a collection guarantee for which an Execution Node has not yet received the full collection. It is used for book-keeping while requesting collections.

func NewMissingCollection added in v0.43.0

func NewMissingCollection(untrusted UntrustedMissingCollection) (*MissingCollection, error)

NewMissingCollection creates a new instance of MissingCollection. Construction MissingCollection allowed only within the constructor

All errors indicate a valid MissingCollection cannot be constructed from the input.

type UntrustedMissingCollection added in v0.43.0

type UntrustedMissingCollection MissingCollection

UntrustedMissingCollection is an untrusted input-only representation of an MissingCollection, used for construction.

This type exists to ensure that constructor functions are invoked explicitly with named fields, which improves clarity and reduces the risk of incorrect field ordering during construction.

An instance of UntrustedMissingCollection should be validated and converted into a trusted MissingCollection using NewMissingCollection constructor.

Jump to

Keyboard shortcuts

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