Documentation
¶
Index ¶
- Variables
- type BlockQueue
- func (q *BlockQueue) GetMissingCollections(blockID flow.Identifier) ([]*MissingCollection, *flow.StateCommitment, error)
- func (q *BlockQueue) HandleBlock(block *flow.Block, parentFinalState *flow.StateCommitment) ([]*MissingCollection, []*entity.ExecutableBlock, error)
- func (q *BlockQueue) HandleCollection(collection *flow.Collection) ([]*entity.ExecutableBlock, error)
- func (q *BlockQueue) OnBlockExecuted(blockID flow.Identifier, commit flow.StateCommitment) ([]*entity.ExecutableBlock, error)
- type MissingCollection
- type UntrustedMissingCollection
Constants ¶
This section is empty.
Variables ¶
var ErrMissingParent = fmt.Errorf("missing parent block")
Functions ¶
This section is empty.
Types ¶
type BlockQueue ¶
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.