Documentation ¶
Index ¶
- type Collector
- func (c *Collector) AddInvalidProposal(proposal *maxbftpb.ProposalData)
- func (c *Collector) AddPendingVote(vote *maxbftpb.VoteData) error
- func (c *Collector) AddVote(vote *maxbftpb.VoteData) error
- func (c *Collector) GetInvalidProposal(blockId string) *maxbftpb.ProposalData
- func (c *Collector) GetVotesByView(view uint64) []*maxbftpb.VoteData
- func (c *Collector) PruneView(view uint64)
- func (c *Collector) SwitchEpoch(contract *maxbftpb.GovernanceContract)
- func (c *Collector) TryBuildQc(proposal *maxbftpb.ProposalData) (*maxbftpb.QuorumCert, error)
- type Voter
- type VoterImpl
- func (v *VoterImpl) AddVote(vote *maxbft.VoteData)
- func (v *VoterImpl) GenerateVote(proposal *maxbft.ProposalData, curView uint64, rejectTxIds []string) (*maxbft.VoteData, error)
- func (v *VoterImpl) GetVote(view uint64) *maxbft.VoteData
- func (v *VoterImpl) HasVote(view uint64) bool
- func (v *VoterImpl) PruneView(view uint64)
- func (v *VoterImpl) SwitchEpoch(contract *maxbft.GovernanceContract, lastView uint64)
- type VotesCollector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is an implementation of VotesCollector interface
func (*Collector) AddInvalidProposal ¶ added in v3.0.1
func (c *Collector) AddInvalidProposal(proposal *maxbftpb.ProposalData)
AddInvalidProposal adds an invalid proposal to c.invalidProposals if not exists
func (*Collector) AddPendingVote ¶
AddPendingVote add a vote to pending votes cache
func (*Collector) AddVote ¶
AddVote add a vote to votes cache
func (*Collector) GetInvalidProposal ¶ added in v3.0.1
func (c *Collector) GetInvalidProposal(blockId string) *maxbftpb.ProposalData
GetInvalidProposal queries invalid proposal from c.invalidProposals and returns it if exists
func (*Collector) GetVotesByView ¶
GetVotesByView retrieve votes by view
func (*Collector) PruneView ¶
PruneView prune votes that before specified view from votes cache and pending votes cache
func (*Collector) SwitchEpoch ¶
func (c *Collector) SwitchEpoch(contract *maxbftpb.GovernanceContract)
SwitchEpoch update the state to a new epoch
func (*Collector) TryBuildQc ¶
func (c *Collector) TryBuildQc(proposal *maxbftpb.ProposalData) (*maxbftpb.QuorumCert, error)
TryBuildQc builds a quorum certification for a proposal when valid votes count reaches the quorum
type Voter ¶
type Voter interface { // SwitchEpoch update the state to a new epoch SwitchEpoch(contract *maxbft.GovernanceContract, lastFinalView uint64) // GenerateVote generate vote for a valid proposal with current view GenerateVote(proposal *maxbft.ProposalData, curView uint64, rejectTxIds []string) (*maxbft.VoteData, error) // HasVote judges a specified vote by nodeId and view is in voter's cache or not HasVote(view uint64) bool // AddVote adds a vote to voter's cache AddVote(data *maxbft.VoteData) // PruneView prunes votes before the specified view (it is usually the final view) PruneView(view uint64) // GetVote returns votes by a specified view GetVote(view uint64) *maxbft.VoteData }
Voter used to generate vote
type VoterImpl ¶
type VoterImpl struct {
// contains filtered or unexported fields
}
VoterImpl is an implementation of Voter interface
func (*VoterImpl) AddVote ¶
AddVote adds a vote to voter's cache
func (*VoterImpl) GenerateVote ¶
func (v *VoterImpl) GenerateVote(proposal *maxbft.ProposalData, curView uint64, rejectTxIds []string) ( *maxbft.VoteData, error)
GenerateVote generate vote for a valid proposal with current view
func (*VoterImpl) GetVote ¶
GetVote returns votes by a specified view
func (*VoterImpl) HasVote ¶
HasVote judges a specified vote by view is in voter's cache or not
func (*VoterImpl) PruneView ¶
PruneView prunes votes before the specified view (it is usually the final view)
func (*VoterImpl) SwitchEpoch ¶
func (v *VoterImpl) SwitchEpoch(contract *maxbft.GovernanceContract, lastView uint64)
SwitchEpoch update the state to a new epoch
type VotesCollector ¶
type VotesCollector interface { // PruneView prune votes that before specified view from votes cache and pending votes cache PruneView(view uint64) // AddVote add a vote to votes cache AddVote(vote *maxbftpb.VoteData) error // AddPendingVote add a vote to pending votes cache AddPendingVote(vote *maxbftpb.VoteData) error // SwitchEpoch update the state to a new epoch SwitchEpoch(contract *maxbftpb.GovernanceContract) // TryBuildQc builds a quorum certification for a proposal when valid votes count reaches the quorum TryBuildQc(proposal *maxbftpb.ProposalData) (*maxbftpb.QuorumCert, error) // GetVotesByView retrieve votes by view GetVotesByView(view uint64) []*maxbftpb.VoteData // AddInvalidProposal adds a invalid proposal to the cache AddInvalidProposal(proposal *maxbftpb.ProposalData) // GetInvalidProposal queries an invalidProposal in the cache by the specified block hash and returns it GetInvalidProposal(blockId string) *maxbftpb.ProposalData }
VotesCollector defines a vote collector to collect and process votes, and build qc
func NewVotesCollector ¶
func NewVotesCollector(verifier verifier.Verifier, quorum, minNodes uint, logger protocol.Logger) VotesCollector
NewVotesCollector initial and return aCollector object