vote

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JustTypeInitZero           = JustType(1)
	JustTypeInitOne            = JustType(2)
	JustTypePreVoteSoft        = JustType(3)
	JustTypePreVoteHard        = JustType(4)
	JustTypeMainVoteConflict   = JustType(5)
	JustTypeMainVoteNoConflict = JustType(6)
	JustTypeDecided            = JustType(7)
)
View Source
const (
	CPValueZero    = CPValue(0)
	CPValueOne     = CPValue(1)
	CPValueAbstain = CPValue(2)
)
View Source
const (
	VoteTypePrepare    = Type(1) // prepare vote
	VoteTypePrecommit  = Type(2) // precommit vote
	VoteTypeCPPreVote  = Type(3) // change-proposer:pre-vote
	VoteTypeCPMainVote = Type(4) // change-proposer:main-vote
	VoteTypeCPDecided  = Type(5) // change-proposer:decided
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicCheckError added in v0.15.0

type BasicCheckError struct {
	Reason string
}

BasicCheckError is returned when the basic check on the transaction fails.

func (BasicCheckError) Error added in v0.15.0

func (e BasicCheckError) Error() string

type CPValue added in v0.15.0

type CPValue int8

func (CPValue) String added in v0.15.0

func (v CPValue) String() string

type InvalidSignerError added in v0.15.0

type InvalidSignerError struct {
	Expected crypto.Address
	Got      crypto.Address
}

InvalidSignerError is returned when the vote signer does not match with the public key.

func (InvalidSignerError) Error added in v0.15.0

func (e InvalidSignerError) Error() string

type Just added in v0.15.0

type Just interface {
	Type() JustType
	BasicCheck() error
}

type JustDecided added in v0.15.1

type JustDecided struct {
	QCert *certificate.Certificate `cbor:"1,keyasint"`
}

func (*JustDecided) BasicCheck added in v0.15.1

func (j *JustDecided) BasicCheck() error

func (*JustDecided) Type added in v0.15.1

func (j *JustDecided) Type() JustType

type JustInitOne added in v0.15.0

type JustInitOne struct {
}

func (*JustInitOne) BasicCheck added in v0.15.0

func (j *JustInitOne) BasicCheck() error

func (*JustInitOne) Type added in v0.15.0

func (j *JustInitOne) Type() JustType

type JustInitZero added in v0.15.0

type JustInitZero struct {
	QCert *certificate.Certificate `cbor:"1,keyasint"`
}

func (*JustInitZero) BasicCheck added in v0.15.0

func (j *JustInitZero) BasicCheck() error

func (*JustInitZero) Type added in v0.15.0

func (j *JustInitZero) Type() JustType

type JustMainVoteConflict added in v0.15.0

type JustMainVoteConflict struct {
	Just0 Just
	Just1 Just
}

func (*JustMainVoteConflict) BasicCheck added in v0.15.0

func (j *JustMainVoteConflict) BasicCheck() error

func (*JustMainVoteConflict) Type added in v0.15.0

func (j *JustMainVoteConflict) Type() JustType

type JustMainVoteNoConflict added in v0.15.0

type JustMainVoteNoConflict struct {
	QCert *certificate.Certificate `cbor:"1,keyasint"`
}

func (*JustMainVoteNoConflict) BasicCheck added in v0.15.0

func (j *JustMainVoteNoConflict) BasicCheck() error

func (*JustMainVoteNoConflict) Type added in v0.15.0

func (j *JustMainVoteNoConflict) Type() JustType

type JustPreVoteHard added in v0.15.0

type JustPreVoteHard struct {
	QCert *certificate.Certificate `cbor:"1,keyasint"`
}

func (*JustPreVoteHard) BasicCheck added in v0.15.0

func (j *JustPreVoteHard) BasicCheck() error

func (*JustPreVoteHard) Type added in v0.15.0

func (j *JustPreVoteHard) Type() JustType

type JustPreVoteSoft added in v0.15.0

type JustPreVoteSoft struct {
	QCert *certificate.Certificate `cbor:"1,keyasint"`
}

func (*JustPreVoteSoft) BasicCheck added in v0.15.0

func (j *JustPreVoteSoft) BasicCheck() error

func (*JustPreVoteSoft) Type added in v0.15.0

func (j *JustPreVoteSoft) Type() JustType

type JustType added in v0.15.0

type JustType uint8

func (JustType) String added in v0.15.0

func (t JustType) String() string

type Type

type Type int

func (Type) IsValid

func (t Type) IsValid() bool

func (Type) String

func (t Type) String() string

type Vote

type Vote struct {
	// contains filtered or unexported fields
}

Vote is a struct that represents a consensus vote.

func NewCPDecidedVote added in v0.15.1

func NewCPDecidedVote(blockHash hash.Hash, height uint32, round int16,
	cpRound int16, cpValue CPValue, just Just, signer crypto.Address,
) *Vote

NewCPDecidedVote creates a new cp:Decided with the specified parameters.

func NewCPMainVote added in v0.15.0

func NewCPMainVote(blockHash hash.Hash, height uint32, round int16,
	cpRound int16, cpValue CPValue, just Just, signer crypto.Address,
) *Vote

NewCPMainVote creates a new cp:MAIN-VOTE with the specified parameters.

func NewCPPreVote added in v0.15.0

func NewCPPreVote(blockHash hash.Hash, height uint32, round int16,
	cpRound int16, cpValue CPValue, just Just, signer crypto.Address,
) *Vote

NewCPPreVote creates a new cp:PRE-VOTE with the specified parameters.

func NewPrecommitVote added in v0.15.0

func NewPrecommitVote(blockHash hash.Hash, height uint32, round int16, signer crypto.Address) *Vote

NewPrecommitVote creates a new PRECOMMIT with the specified parameters.

func NewPrepareVote added in v0.15.0

func NewPrepareVote(blockHash hash.Hash, height uint32, round int16, signer crypto.Address) *Vote

NewPrepareVote creates a new PREPARE with the specified parameters.

func (*Vote) BasicCheck added in v0.15.0

func (v *Vote) BasicCheck() error

BasicCheck performs a basic check on the vote.

func (*Vote) BlockHash

func (v *Vote) BlockHash() hash.Hash

BlockHash returns the hash of the block in the vote.

func (*Vote) CPJust added in v0.15.0

func (v *Vote) CPJust() Just

CPValue returns the change proposer justification for the vote.

func (*Vote) CPRound added in v0.15.0

func (v *Vote) CPRound() int16

CPRound returns the change proposer round the vote.

func (*Vote) CPValue added in v0.15.0

func (v *Vote) CPValue() CPValue

CPValue returns the change proposer value the vote.

func (*Vote) Hash

func (v *Vote) Hash() hash.Hash

Hash calculates the hash of the vote.

func (*Vote) Height

func (v *Vote) Height() uint32

Height returns the height of the block in the vote.

func (*Vote) IsCPVote added in v0.19.0

func (v *Vote) IsCPVote() bool

func (*Vote) MarshalCBOR

func (v *Vote) MarshalCBOR() ([]byte, error)

MarshalCBOR marshals the vote into CBOR format.

func (*Vote) Round

func (v *Vote) Round() int16

Round returns the round the vote.

func (*Vote) SetSignature

func (v *Vote) SetSignature(sig *bls.Signature)

SetSignature sets the signature of the vote.

func (*Vote) SignBytes

func (v *Vote) SignBytes() []byte

SignBytes generates the bytes to be signed for the vote.

func (*Vote) Signature

func (v *Vote) Signature() *bls.Signature

Signature returns the signature of the vote.

func (*Vote) Signer

func (v *Vote) Signer() crypto.Address

Signer returns the address of the signer of the vote.

func (*Vote) String added in v0.15.0

func (v *Vote) String() string

func (*Vote) Type

func (v *Vote) Type() Type

Type returns the type of the vote.

func (*Vote) UnmarshalCBOR

func (v *Vote) UnmarshalCBOR(bs []byte) error

UnmarshalCBOR unmarshals the vote from CBOR format.

func (*Vote) Verify

func (v *Vote) Verify(pubKey *bls.PublicKey) error

Verify checks the signature of the vote with the given public key.

Jump to

Keyboard shortcuts

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