Documentation ¶
Index ¶
- func JobID(blockID flow.Identifier) module.JobID
- func JobToBlock(job module.Job) (*flow.Block, error)
- type BlockConsumer
- func (c *BlockConsumer) Done() <-chan struct{}
- func (c *BlockConsumer) NotifyJobIsDone(jobID module.JobID)
- func (c *BlockConsumer) OnBlockIncorporated(*model.Block)
- func (c *BlockConsumer) OnDoubleProposeDetected(*model.Block, *model.Block)
- func (c *BlockConsumer) OnFinalizedBlock(*model.Block)
- func (c *BlockConsumer) Ready() <-chan struct{}
- type BlockJob
- type FinalizedBlockReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockConsumer ¶
type BlockConsumer struct {
// contains filtered or unexported fields
}
BlockConsumer listens to the OnFinalizedBlock event and notifies the consumer to check in the job queue (i.e., its block reader) for new block jobs.
func NewBlockConsumer ¶
func NewBlockConsumer(log zerolog.Logger, processedHeight storage.ConsumerProgress, blocks storage.Blocks, state protocol.State, blockProcessor assigner.FinalizedBlockProcessor, maxProcessing int64) (*BlockConsumer, uint64, error)
NewBlockConsumer creates a new consumer and returns the default processed index for initializing the processed index in storage.
func (*BlockConsumer) Done ¶
func (c *BlockConsumer) Done() <-chan struct{}
func (*BlockConsumer) NotifyJobIsDone ¶
func (c *BlockConsumer) NotifyJobIsDone(jobID module.JobID)
NotifyJobIsDone is invoked by the worker to let the consumer know that it is done processing a (block) job.
func (*BlockConsumer) OnBlockIncorporated ¶
func (c *BlockConsumer) OnBlockIncorporated(*model.Block)
OnBlockIncorporated is to implement FinalizationConsumer
func (*BlockConsumer) OnDoubleProposeDetected ¶
func (c *BlockConsumer) OnDoubleProposeDetected(*model.Block, *model.Block)
OnDoubleProposeDetected is to implement FinalizationConsumer
func (*BlockConsumer) OnFinalizedBlock ¶
func (c *BlockConsumer) OnFinalizedBlock(*model.Block)
OnFinalizedBlock implements FinalizationConsumer, and is invoked by the follower engine whenever a new block is finalized. In this implementation for block consumer, invoking OnFinalizedBlock is enough to only notify the consumer to check its internal queue and move its processing index ahead to the next height if there are workers available. The consumer retrieves the new blocks from its block reader module, hence it does not need to use the parameter of OnFinalizedBlock here.
func (*BlockConsumer) Ready ¶
func (c *BlockConsumer) Ready() <-chan struct{}
type BlockJob ¶
BlockJob implements the Job interface. It converts a Block into a Job to be used by job queue.
In current architecture, BlockJob represents a finalized block enqueued to be processed by the BlockConsumer that implements the JobQueue interface.
func BlockToJob ¶ added in v0.17.0
BlockToJob converts the block to a BlockJob.
type FinalizedBlockReader ¶
type FinalizedBlockReader struct {
// contains filtered or unexported fields
}
FinalizedBlockReader provides an abstraction for consumers to read blocks as job.
func NewFinalizedBlockReader ¶ added in v0.17.0
func NewFinalizedBlockReader(state protocol.State, blocks storage.Blocks) *FinalizedBlockReader
NewFinalizedBlockReader creates and returns a FinalizedBlockReader.
func (FinalizedBlockReader) AtIndex ¶
func (r FinalizedBlockReader) AtIndex(index uint64) (module.Job, error)
AtIndex returns the block job at the given index. The block job at an index is just the finalized block at that index (i.e., height).
func (FinalizedBlockReader) Head ¶
func (r FinalizedBlockReader) Head() (uint64, error)
Head returns the last finalized height as job index.