endorsement

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.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 NewEndorsement

func NewEndorsement(object *ConsensusVote, endorserPubKey keypair.PublicKey, 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

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

func (en *Endorsement) FromProtoMsg(endorsePb *iproto.Endorsement) error

FromProtoMsg creates an endorsement from endorsePb

func (*Endorsement) MarshalLogObject

func (en *Endorsement) MarshalLogObject(oe zapcore.ObjectEncoder) error

MarshalLogObject marshals the endorsement to a zap object

func (*Endorsement) Serialize

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() *iproto.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 NewSet

func NewSet(blkHash []byte) *Set

NewSet creates an endorsement set

func (*Set) AddEndorsement

func (s *Set) AddEndorsement(en *Endorsement) error

AddEndorsement adds an endorsement with the right block hash and signature

func (*Set) BlockHash

func (s *Set) BlockHash() []byte

BlockHash returns the hash of the endorsed block

func (*Set) DeleteEndorsements

func (s *Set) DeleteEndorsements(topics map[ConsensusVoteTopic]bool, round uint32)

DeleteEndorsements deletes endorsements of the given topics and before round

func (*Set) EndorsementsLogger

func (s *Set) EndorsementsLogger(l *zap.Logger) *zap.Logger

EndorsementsLogger logs the details of the endorsements in the set

func (*Set) FromProto

func (s *Set) FromProto(sPb *iproto.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) Round

func (s *Set) Round() uint32

Round returns the locked round number

func (*Set) SetRound

func (s *Set) SetRound(round uint32)

SetRound sets the locked round number

func (*Set) SubSet

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() *iproto.EndorsementSet

ToProto convert the endorsement set to protobuf

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL