events

package
v0.37.7 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinalizationActor

type FinalizationActor struct {
	// contains filtered or unexported fields
}

FinalizationActor is an event responder worker which can be embedded in a component to simplify the plumbing required to respond to block finalization events. This worker is designed to respond to a newly finalized blocks on a best-effort basis, meaning that it may skip blocks when finalization occurs more quickly. CAUTION: This is suitable for use only when the handler can tolerate skipped blocks.

func NewFinalizationActor

NewFinalizationActor creates a new FinalizationActor, and returns the worker routine and event consumer required to operate it. The caller MUST:

  • start the returned component.ComponentWorker function
  • subscribe the returned FinalizationActor to ProcessLatestFinalizedBlock events

func (*FinalizationActor) OnBlockIncorporated

func (actor *FinalizationActor) OnBlockIncorporated(*model.Block)

func (*FinalizationActor) OnDoubleProposeDetected

func (actor *FinalizationActor) OnDoubleProposeDetected(*model.Block, *model.Block)

func (*FinalizationActor) OnFinalizedBlock

func (actor *FinalizationActor) OnFinalizedBlock(block *model.Block)

OnFinalizedBlock receives block finalization events. It updates the newest finalized block tracker and notifies the worker thread.

type FinalizedHeaderCache

type FinalizedHeaderCache struct {
	*FinalizationActor // implement hotstuff.FinalizationConsumer
	// contains filtered or unexported fields
}

FinalizedHeaderCache caches a copy of the most recently finalized block header by consuming BlockFinalized events from HotStuff, using a FinalizationActor. The constructor returns both the cache and a worker function.

NOTE: The protocol state already guarantees that state.Final().Head() will be cached, however, since the protocol state is shared among many components, there may be high contention on its cache. The FinalizedHeaderCache can be used in place of state.Final().Head() to avoid read contention with other components.

func NewFinalizedHeaderCache

func NewFinalizedHeaderCache(state protocol.State) (*FinalizedHeaderCache, component.ComponentWorker, error)

NewFinalizedHeaderCache returns a new FinalizedHeaderCache and the ComponentWorker function. The caller MUST:

  • subscribe the `FinalizedHeaderCache` (first return value) to the `FinalizationDistributor` that is distributing the consensus logic's `OnFinalizedBlock` events
  • start the returned ComponentWorker logic (second return value) in a goroutine to maintain the cache.

func (*FinalizedHeaderCache) Get

func (cache *FinalizedHeaderCache) Get() *flow.Header

Get returns the most recently finalized block. Guaranteed to be non-nil after construction.

type ProcessLatestFinalizedBlock

type ProcessLatestFinalizedBlock func(block *model.Block) error

ProcessLatestFinalizedBlock is invoked when a new block is finalized. It is possible that blocks will be skipped.

Jump to

Keyboard shortcuts

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