Documentation ¶
Index ¶
- Variables
- type ConsensusVote
- type ConsensusVoteTopic
- type Endorsement
- func (en *Endorsement) ConsensusVote() *ConsensusVote
- func (en *Endorsement) Deserialize(bs []byte) error
- func (en *Endorsement) Endorser() string
- func (en *Endorsement) EndorserPublicKey() keypair.PublicKey
- func (en *Endorsement) FromProtoMsg(endorsePb *iotextypes.Endorsement) error
- func (en *Endorsement) MarshalLogObject(oe zapcore.ObjectEncoder) error
- func (en *Endorsement) Serialize() ([]byte, error)
- func (en *Endorsement) Signature() []byte
- func (en *Endorsement) ToProtoMsg() *iotextypes.Endorsement
- func (en *Endorsement) VerifySignature() bool
- type Set
- func (s *Set) AddEndorsement(en *Endorsement) error
- func (s *Set) BlockHash() []byte
- func (s *Set) DeleteEndorsements(topics map[ConsensusVoteTopic]bool, round uint32)
- func (s *Set) EndorsementsLogger(l *zap.Logger) *zap.Logger
- func (s *Set) FromProto(sPb *iotextypes.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) SubSet(topic ConsensusVoteTopic) (*Set, error)
- func (s *Set) ToProto() *iotextypes.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 []byte 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 []byte, height uint64, round uint32, topic ConsensusVoteTopic) *ConsensusVote
NewConsensusVote creates a consensus vote
func (*ConsensusVote) Hash ¶
func (en *ConsensusVote) Hash() hash.Hash256
Hash returns a Hash256 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 NewEndorsement ¶
func NewEndorsement(object *ConsensusVote, endorserPriKey keypair.PrivateKey, endorserAddr string) *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) Deserialize ¶ added in v0.4.4
func (en *Endorsement) Deserialize(bs []byte) error
Deserialize converts a byte array to endorsement
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) FromProtoMsg ¶ added in v0.4.4
func (en *Endorsement) FromProtoMsg(endorsePb *iotextypes.Endorsement) error
FromProtoMsg creates an endorsement from endorsePb
func (*Endorsement) MarshalLogObject ¶ added in v0.4.4
func (en *Endorsement) MarshalLogObject(oe zapcore.ObjectEncoder) error
MarshalLogObject marshals the endorsement to a zap object
func (*Endorsement) Serialize ¶ added in v0.4.4
func (en *Endorsement) Serialize() ([]byte, error)
Serialize converts an endorsement to bytes
func (*Endorsement) Signature ¶
func (en *Endorsement) Signature() []byte
Signature returns the signature of this endorsement
func (*Endorsement) ToProtoMsg ¶
func (en *Endorsement) ToProtoMsg() *iotextypes.Endorsement
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) DeleteEndorsements ¶ added in v0.4.4
func (s *Set) DeleteEndorsements(topics map[ConsensusVoteTopic]bool, round uint32)
DeleteEndorsements deletes endorsements of the given topics and before round
func (*Set) EndorsementsLogger ¶ added in v0.4.4
EndorsementsLogger logs the details of the endorsements in the set
func (*Set) FromProto ¶
func (s *Set) FromProto(sPb *iotextypes.EndorsementSet) error
FromProto converts protobuf to endorsement set
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
func (*Set) SubSet ¶ added in v0.4.4
func (s *Set) SubSet(topic ConsensusVoteTopic) (*Set, error)
SubSet returns a subset of the set with specified topic
func (*Set) ToProto ¶
func (s *Set) ToProto() *iotextypes.EndorsementSet
ToProto convert the endorsement set to protobuf