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
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
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 ¶
func (m *MissingCollection) ID() flow.Identifier