Documentation ¶
Index ¶
- Constants
- Variables
- func CountNumFromVotes(qc *maxbftpb.QuorumCert, minNodes uint) (votedBlockNum, votedRejectedNum uint, rejectedTxIds []string, err error)
- func VerifyVotes(ac protocol.AccessControlProvider, validThreshold uint, ...) (reachThreshold bool, err error)
- type Validator
- func (v *Validator) BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error
- func (v *Validator) CheckRejectQcLeader(proposal *maxbftpb.ProposalData) error
- func (v *Validator) GetLeader(view uint64) string
- func (v *Validator) IsLegalForNilBlock(block *common.Block) bool
- func (v *Validator) SwitchEpoch(contract *maxbftpb.GovernanceContract)
- func (v *Validator) ValidateJustifyQc(proposal *maxbft.ProposalData) error
- func (v *Validator) ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert, ...) (*consensus.VerifyResult, error)
- func (v *Validator) ValidateQc(qc *maxbftpb.QuorumCert, selfCreate bool) error
- func (v *Validator) ValidateVote(vote *maxbftpb.VoteData, proposal *maxbftpb.ProposalData) error
- type Verifier
Constants ¶
const MinQuorumForQc = 3
MinQuorumForQc defines the minimum votes count for a quorum certification
Variables ¶
Functions ¶
Types ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is an implementation of Verifier interface
func (*Validator) BaseCheck ¶
func (v *Validator) BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error
BaseCheck implements basic check for proposals
func (*Validator) CheckRejectQcLeader ¶ added in v3.0.1
func (v *Validator) CheckRejectQcLeader(proposal *maxbftpb.ProposalData) error
CheckRejectQcLeader checks a rejectQc is from the right leader or not
func (*Validator) GetLeader ¶
GetLeader return the leader for the specified view
func (*Validator) IsLegalForNilBlock ¶
IsLegalForNilBlock the logic is to verify the nil block whether can be generated. If the nearest ancestor blocks are empty or none exist, then no new empty block are allowed to be generated.
func (*Validator) SwitchEpoch ¶
func (v *Validator) SwitchEpoch(contract *maxbftpb.GovernanceContract)
SwitchEpoch Sets the state of the new epoch
func (*Validator) ValidateJustifyQc ¶
func (v *Validator) ValidateJustifyQc(proposal *maxbft.ProposalData) error
ValidateJustifyQc 验证提案中携带的QC
func (*Validator) ValidateProposal ¶
func (v *Validator) ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert, mode protocol.VerifyMode) (*consensus.VerifyResult, error)
ValidateProposal validate specified proposal
type Verifier ¶
type Verifier interface { // BaseCheck implements basic check for proposals BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert, mode protocol.VerifyMode) (*consensus.VerifyResult, error) // ValidateQc Verify the QC aggregated from the local vote, and the // proposal corresponding to the QC has been verified. This behavior // occurs on the leader, which collects votes for proposals to aggregate QC. // selfCreate if qc is created by self which is true. ValidateQc(qc *maxbftpb.QuorumCert, selfCreate bool) error // ValidateJustifyQc Verify the QC carried in the proposal ValidateJustifyQc(proposal *maxbftpb.ProposalData) error // IsLegalForNilBlock the logic is to verify the nil block whether can be generated. IsLegalForNilBlock(block *common.Block) bool // ValidateVote validate specified vote with specified proposal ValidateVote(vote *maxbftpb.VoteData, proposal *maxbftpb.ProposalData) error // GetLeader return the leader for the specified view GetLeader(view uint64) string SwitchEpoch(contract *maxbftpb.GovernanceContract) // CheckRejectQcLeader checks a rejectQc is from the right leader or not CheckRejectQcLeader(proposal *maxbftpb.ProposalData) error }
Verifier defines a verifier used to validate quorum certifications, proposals and blocks
func NewValidator ¶
func NewValidator(validators []string, verifier protocol.BlockVerifier, ac protocol.AccessControlProvider, net protocol.NetService, nodeId string, forks forest.Forester, cache protocol.LedgerCache, epochState *maxbft.GovernanceContract, epochId uint64, logger protocol.Logger, manager epoch.Manager) Verifier
NewValidator initial and return a Validator object