block_queue

package
v0.34.0-crescendo-prev... Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 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

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
}

func (*MissingCollection) ID

Jump to

Keyboard shortcuts

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