voteaggregator

package
v0.26.11 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: AGPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewCollectorFactoryMethod added in v0.23.9

type NewCollectorFactoryMethod = func(view uint64, workers hotstuff.Workers) (hotstuff.VoteCollector, error)

NewCollectorFactoryMethod is a factory method to generate a VoteCollector for concrete view

type PendingStatus

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

PendingStatus keeps track of pending votes for the same block

func NewPendingStatus

func NewPendingStatus() *PendingStatus

NewPendingStatus creates a PendingStatus instance

func (*PendingStatus) AddVote

func (ps *PendingStatus) AddVote(vote *model.Vote) bool

AddVote adds a vote as a pending vote returns false if it has been added before returns true otherwise

type PendingVotes

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

PendingVotes stores all the pending votes for different block proposals

func NewPendingVotes

func NewPendingVotes() *PendingVotes

NewPendingVotes creates a PendingVotes instance

func (*PendingVotes) AddVote

func (pv *PendingVotes) AddVote(vote *model.Vote) bool

AddVote adds a vote as a pending vote returns true if it can be added to a PendingStatus successfully returns false otherwise

type VoteAggregator

type VoteAggregator struct {
	*component.ComponentManager
	// contains filtered or unexported fields
}

VoteAggregator stores the votes and aggregates them into a QC when enough votes have been collected VoteAggregator is designed in a way that it can aggregate votes for collection & consensus clusters that is why implementation relies on dependency injection.

func NewVoteAggregator added in v0.23.9

func NewVoteAggregator(
	log zerolog.Logger,
	notifier hotstuff.Consumer,
	lowestRetainedView uint64,
	collectors hotstuff.VoteCollectors,
) (*VoteAggregator, error)

NewVoteAggregator creates an instance of vote aggregator Note: verifyingProcessorFactory is injected. Thereby, the code is agnostic to the different voting formats of main Consensus vs Collector consensus.

func (*VoteAggregator) AddBlock added in v0.23.9

func (va *VoteAggregator) AddBlock(block *model.Proposal) error

AddBlock notifies the VoteAggregator about a known block so that it can start processing pending votes whose block was unknown. It also verifies the proposer vote of a block, and return whether the proposer signature is valid. Expected error returns during normal operations: * model.InvalidBlockError if the proposer's vote for its own block is invalid * mempool.DecreasingPruningHeightError if the block's view has already been pruned

func (*VoteAggregator) AddVote added in v0.23.9

func (va *VoteAggregator) AddVote(vote *model.Vote)

AddVote checks if vote is stale and appends vote into processing queue actual vote processing will be called in other dispatching goroutine.

func (*VoteAggregator) InvalidBlock added in v0.23.9

func (va *VoteAggregator) InvalidBlock(proposal *model.Proposal) error

InvalidBlock notifies the VoteAggregator about an invalid proposal, so that it can process votes for the invalid block and slash the voters. Expected error returns during normal operations: * mempool.DecreasingPruningHeightError if proposal's view has already been pruned

func (*VoteAggregator) OnFinalizedBlock added in v0.25.0

func (va *VoteAggregator) OnFinalizedBlock(block *model.Block)

OnFinalizedBlock implements the `OnFinalizedBlock` callback from the `hotstuff.FinalizationConsumer`

(1) Informs sealing.Core about finalization of respective block.

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 (*VoteAggregator) PruneUpToView added in v0.23.9

func (va *VoteAggregator) PruneUpToView(lowestRetainedView uint64)

PruneUpToView deletes all votes _below_ to the given view, as well as related indices. 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.

type VoteCollectors added in v0.23.9

type VoteCollectors struct {
	*component.ComponentManager
	// contains filtered or unexported fields
}

VoteCollectors implements management of multiple vote collectors indexed by view. Implements hotstuff.VoteCollectors interface. Creating a VoteCollector for a particular view is lazy (instances are created on demand). This structure is concurrently safe.

func NewVoteCollectors added in v0.23.9

func NewVoteCollectors(logger zerolog.Logger, lowestRetainedView uint64, workerPool hotstuff.Workerpool, factoryMethod NewCollectorFactoryMethod) *VoteCollectors

func (*VoteCollectors) GetOrCreateCollector added in v0.23.9

func (v *VoteCollectors) GetOrCreateCollector(view uint64) (hotstuff.VoteCollector, bool, error)

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

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

Expected error returns during normal operations:

  • mempool.DecreasingPruningHeightError - in case view is lower than lowestRetainedView

func (*VoteCollectors) PruneUpToView added in v0.23.9

func (v *VoteCollectors) PruneUpToView(lowestRetainedView uint64)

PruneUpToView prunes the vote 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