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) 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 ¶
View Source
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) 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) (*consensus.VerifyResult, error)
ValidateProposal validate specified proposal
type Verifier ¶
type Verifier interface { BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) (*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(block *common.Block) bool ValidateVote(vote *maxbftpb.VoteData, proposal *maxbftpb.ProposalData) error GetLeader(view uint64) string SwitchEpoch(contract *maxbftpb.GovernanceContract) }
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
Click to show internal directories.
Click to hide internal directories.