github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/consensus/hotstuff/vote_aggregator.go (about) 1 package hotstuff 2 3 import ( 4 "github.com/onflow/flow-go/consensus/hotstuff/model" 5 "github.com/onflow/flow-go/module" 6 ) 7 8 // VoteAggregator verifies and aggregates votes to build QC. 9 // When enough votes have been collected, it builds a QC and send it to the EventLoop 10 // VoteAggregator also detects protocol violation, including invalid votes, double voting etc, and 11 // notifies a HotStuff consumer for slashing. 12 type VoteAggregator interface { 13 module.ReadyDoneAware 14 module.Startable 15 16 // AddVote verifies and aggregates a vote. 17 // The voting block could either be known or unknown. 18 // If the voting block is unknown, the vote won't be processed until AddBlock is called with the block. 19 // This method can be called concurrently, votes will be queued and processed asynchronously. 20 AddVote(vote *model.Vote) 21 22 // AddBlock notifies the VoteAggregator that it should start processing votes for the given block. 23 // The input block is queued internally within the `VoteAggregator` and processed _asynchronously_ 24 // by the VoteAggregator's internal worker routines. 25 // CAUTION: we expect that the input block's validity has been confirmed prior to calling AddBlock, 26 // including the proposer's signature. Otherwise, VoteAggregator might crash or exhibit undefined 27 // behaviour. 28 AddBlock(block *model.Proposal) 29 30 // InvalidBlock notifies the VoteAggregator about an invalid proposal, so that it 31 // can process votes for the invalid block and slash the voters. 32 // No errors are expected during normal operations 33 InvalidBlock(block *model.Proposal) error 34 35 // PruneUpToView deletes all votes _below_ to the given view, as well as 36 // related indices. We only retain and process whose view is equal or larger 37 // than `lowestRetainedView`. If `lowestRetainedView` is smaller than the 38 // previous value, the previous value is kept and the method call is a NoOp. 39 PruneUpToView(view uint64) 40 }