Documentation ¶
Index ¶
- Variables
- type ConsensusVote
- type ConsensusVoteTopic
- type Endorsement
- type Set
- func (s *Set) AddEndorsement(en *Endorsement) error
- func (s *Set) BlockHash() hash.Hash32B
- func (s *Set) FromProto(sPb *iproto.EndorsementSet) error
- func (s *Set) NumOfValidEndorsements(topics map[ConsensusVoteTopic]bool, endorsers []string) int
- func (s *Set) Round() uint32
- func (s *Set) SetRound(round uint32)
- func (s *Set) ToProto() *iproto.EndorsementSet
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExpiredEndorsement indicates that the endorsement is from previous rounds ErrExpiredEndorsement = errors.New("the endorsement is from previous round") // ErrInvalidHash indicates that the endorsement hash is different from the set ErrInvalidHash = errors.New("the endorsement hash is different from the set") // ErrInvalidEndorsement indicates that the signature of the endorsement is invalid ErrInvalidEndorsement = errors.New("the endorsement's signature is invalid") )
Functions ¶
This section is empty.
Types ¶
type ConsensusVote ¶
type ConsensusVote struct { BlkHash hash.Hash32B Height uint64 Round uint32 Topic ConsensusVoteTopic }
ConsensusVote is a vote on a given topic for a block on a specific height
func NewConsensusVote ¶
func NewConsensusVote(blkHash hash.Hash32B, height uint64, round uint32, topic ConsensusVoteTopic) *ConsensusVote
NewConsensusVote creates a consensus vote
func (*ConsensusVote) Hash ¶
func (en *ConsensusVote) Hash() hash.Hash32B
Hash returns a Hash32B for the consensus vote
type ConsensusVoteTopic ¶
type ConsensusVoteTopic uint8
ConsensusVoteTopic defines the topic of an consensus vote
const ( // PROPOSAL stands for an consensus vote to endorse a block proposal PROPOSAL ConsensusVoteTopic = 0 // LOCK stands for an consensus vote to endorse a lock on a proposed block LOCK ConsensusVoteTopic = 1 // COMMIT stands for an consensus vote to endorse a block commit COMMIT ConsensusVoteTopic = 2 )
type Endorsement ¶
type Endorsement struct {
// contains filtered or unexported fields
}
Endorsement is a stamp on a consensus vote
func FromProtoMsg ¶
func FromProtoMsg(endorsePb *iproto.EndorsePb) (*Endorsement, error)
FromProtoMsg creates an endorsement from endorsePb
func NewEndorsement ¶
func NewEndorsement(object *ConsensusVote, endorser *iotxaddress.Address) *Endorsement
NewEndorsement creates an Endorsement for an consensus vote
func (*Endorsement) ConsensusVote ¶
func (en *Endorsement) ConsensusVote() *ConsensusVote
ConsensusVote returns the Object of the endorse for signature
func (*Endorsement) Endorser ¶
func (en *Endorsement) Endorser() string
Endorser returns the endorser of this endorsement
func (*Endorsement) EndorserPublicKey ¶
func (en *Endorsement) EndorserPublicKey() keypair.PublicKey
EndorserPublicKey returns the public key of the endorser of this endorsement
func (*Endorsement) Signature ¶
func (en *Endorsement) Signature() []byte
Signature returns the signature of this endorsement
func (*Endorsement) ToProtoMsg ¶
func (en *Endorsement) ToProtoMsg() *iproto.EndorsePb
ToProtoMsg converts an endorsement to endorse proto
func (*Endorsement) VerifySignature ¶
func (en *Endorsement) VerifySignature() bool
VerifySignature verifies that the endorse with pubkey
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a collection of endorsements for block
func (*Set) AddEndorsement ¶
func (s *Set) AddEndorsement(en *Endorsement) error
AddEndorsement adds an endorsement with the right block hash and signature
func (*Set) NumOfValidEndorsements ¶
func (s *Set) NumOfValidEndorsements(topics map[ConsensusVoteTopic]bool, endorsers []string) int
NumOfValidEndorsements returns the number of endorsements of the given topics and the endorsers