voteaggregator

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 {
	// contains filtered or unexported fields
}

VoteAggregator stores the votes and aggregates them into a QC when enough votes have been collected

func New

func New(notifier hotstuff.Consumer, highestPrunedView uint64, committee hotstuff.Committee, voteValidator hotstuff.Validator, signer hotstuff.SignerVerifier) *VoteAggregator

New creates an instance of vote aggregator

func (*VoteAggregator) BuildQCOnReceivedBlock

func (va *VoteAggregator) BuildQCOnReceivedBlock(block *model.Block) (*flow.QuorumCertificate, bool, error)

BuildQCOnReceivedBlock will attempt to build a QC for the given block when there are votes with enough stakes. It's idempotent. Meaning, calling it again with the same block returns the same result. It assumes that the proposer's vote has been stored by calling StoreProposerVote It assumes the block has been validated. It returns (qc, true, nil) if a QC is built It returns (nil, false, nil) if not enough votes to build a QC. It returns (nil, false, nil) if the block is stale It returns (nil, false, err) if there is an unknown error

func (*VoteAggregator) PruneByView

func (va *VoteAggregator) PruneByView(view uint64)

PruneByView will delete all votes equal or below to the given view, as well as related indexes.

func (*VoteAggregator) StorePendingVote

func (va *VoteAggregator) StorePendingVote(vote *model.Vote) (bool, error)

StorePendingVote stores the vote as a pending vote assuming the caller has checked that the voting block is currently missing. It's idempotent. Meaning, calling it again with the same block returns the same result. Note: Validations on these pending votes will be postponed until the block has been received.

func (*VoteAggregator) StoreProposerVote

func (va *VoteAggregator) StoreProposerVote(vote *model.Vote) bool

StoreProposerVote stores the vote for a block that was proposed.

func (*VoteAggregator) StoreVoteAndBuildQC

func (va *VoteAggregator) StoreVoteAndBuildQC(vote *model.Vote, block *model.Block) (*flow.QuorumCertificate, bool, error)

StoreVoteAndBuildQC stores the vote assuming the caller has checked that the voting block is incorporated, and returns a QC if there are votes with enough stakes. It's idempotent. Meaning, calling it again with the same block returns the same result. The VoteAggregator builds a QC as soon as the number of votes allow this. While subsequent votes (past the required threshold) are not included in the QC anymore, VoteAggregator ALWAYS returns the same QC as the one returned before.

type VotingStatus

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

VotingStatus keeps track of incorporated votes for the same block

func NewVotingStatus

func NewVotingStatus(block *model.Block, stakeThreshold uint64, signer hotstuff.SignerVerifier) *VotingStatus

NewVotingStatus creates a new Voting Status instance

func (*VotingStatus) AddVote

func (vs *VotingStatus) AddVote(vote *model.Vote, voter *flow.Identity)

AddVote add votes to the list, and accumulates the stake assume votes are valid. duplicate votes will not be accumulated again

func (*VotingStatus) CanBuildQC

func (vs *VotingStatus) CanBuildQC() bool

CanBuildQC check whether the

func (*VotingStatus) TryBuildQC

func (vs *VotingStatus) TryBuildQC() (*flow.QuorumCertificate, bool, error)

TryBuildQC returns a QC if the existing votes are enought to build a QC, otherwise an error will be returned.

Jump to

Keyboard shortcuts

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