Help us shape the future of Go! Take the 2026 Go Developer Survey

timeoutaggregator

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeoutAggregator

type TimeoutAggregator struct {
	*component.ComponentManager
	notifications.NoopConsumer
	// contains filtered or unexported fields
}

TimeoutAggregator stores the timeout objects and aggregates them into a TC when enough TOs have been collected. It's safe to use in concurrent environment.

func NewTimeoutAggregator

func NewTimeoutAggregator(log zerolog.Logger,
	hotstuffMetrics module.HotstuffMetrics,
	engineMetrics module.EngineMetrics,
	mempoolMetrics module.MempoolMetrics,
	lowestRetainedView uint64,
	collectors hotstuff.TimeoutCollectors,
) (*TimeoutAggregator, error)

NewTimeoutAggregator creates an instance of timeout aggregator. No errors are expected during normal operations.

func (*TimeoutAggregator) AddTimeout

func (t *TimeoutAggregator) AddTimeout(timeoutObject *model.TimeoutObject)

AddTimeout checks if TO is stale and appends TO to processing queue. The actual processing will be done asynchronously by the `TimeoutAggregator`'s internal worker routines.

func (*TimeoutAggregator) OnViewChange

func (t *TimeoutAggregator) OnViewChange(_, newView uint64)

OnViewChange implements the `OnViewChange` callback from the `hotstuff.Consumer`. We notify the enteringViewProcessingLoop worker, which then prunes up to the active view. CAUTION: the input to this callback is treated as trusted; precautions should be taken that messages from external nodes cannot be considered as inputs to this function

func (*TimeoutAggregator) PruneUpToView

func (t *TimeoutAggregator) PruneUpToView(lowestRetainedView uint64)

PruneUpToView deletes all `TimeoutCollector`s _below_ to the given view, as well as related indices. We only retain and process `TimeoutCollector`s, whose view is equal or larger than `lowestRetainedView`. If `lowestRetainedView` is smaller than the previous value, the previous value is kept and the method call is a NoOp.

type TimeoutCollectors

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

TimeoutCollectors implements management of multiple timeout collectors indexed by view. Implements hotstuff.TimeoutCollectors interface. Creating a TimeoutCollector for a particular view is lazy (instances are created on demand). This structure is concurrently safe. TODO: once VoteCollectors gets updated to stop managing worker pool we can merge VoteCollectors and TimeoutCollectors using generics

func NewTimeoutCollectors

func NewTimeoutCollectors(log zerolog.Logger, metrics module.HotstuffMetrics, lowestRetainedView uint64, collectorFactory hotstuff.TimeoutCollectorFactory) *TimeoutCollectors

func (*TimeoutCollectors) GetOrCreateCollector

func (t *TimeoutCollectors) GetOrCreateCollector(view uint64) (hotstuff.TimeoutCollector, bool, error)

GetOrCreateCollector retrieves the hotstuff.TimeoutCollector for the specified view or creates one if none exists.

  • (collector, true, nil) if no collector can be found by the view, and a new collector was created.
  • (collector, false, nil) if the collector can be found by the view
  • (nil, false, error) if running into any exception creating the timeout collector state machine

Expected error returns during normal operations:

  • mempool.BelowPrunedThresholdError if view is below the pruning threshold
  • model.ErrViewForUnknownEpoch if view is not yet pruned but no epoch containing the given view is known, this error

can be returned from factory method.

func (*TimeoutCollectors) PruneUpToView

func (t *TimeoutCollectors) PruneUpToView(lowestRetainedView uint64)

PruneUpToView prunes the timeout collectors with views _below_ the given value, i.e. we only retain and process whose view is equal or larger than `lowestRetainedView`. If `lowestRetainedView` is smaller than the previous value, the previous value is kept and the method call is a NoOp.

Jump to

Keyboard shortcuts

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