vote

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JustTypeInitNo             = JustType(1)
	JustTypeInitYes            = JustType(2)
	JustTypePreVoteSoft        = JustType(3)
	JustTypePreVoteHard        = JustType(4)
	JustTypeMainVoteConflict   = JustType(5)
	JustTypeMainVoteNoConflict = JustType(6)
	JustTypeDecided            = JustType(7)
)
View Source
const (
	CPValueNo      = CPValue(0)
	CPValueYes     = CPValue(1)
	CPValueAbstain = CPValue(2)
)
View Source
const (
	VoteTypePrepare    = Type(1) // Deprecated  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

type BasicCheckError struct {
	Reason string
}

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

func (BasicCheckError) Error

func (e BasicCheckError) Error() string

type CPValue

type CPValue int8

func (CPValue) String

func (v CPValue) String() string

type InvalidSignerError

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

func (e InvalidSignerError) Error() string

type Just

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

type JustDecided

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

func (*JustDecided) BasicCheck

func (j *JustDecided) BasicCheck() error

func (*JustDecided) Type

func (*JustDecided) Type() JustType

type JustInitNo

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

func (*JustInitNo) BasicCheck

func (j *JustInitNo) BasicCheck() error

func (*JustInitNo) Type

func (*JustInitNo) Type() JustType

type JustInitYes

type JustInitYes struct {
}

func (*JustInitYes) BasicCheck

func (*JustInitYes) BasicCheck() error

func (*JustInitYes) Type

func (*JustInitYes) Type() JustType

type JustMainVoteConflict

type JustMainVoteConflict struct {
	JustNo  Just
	JustYes Just
}

func (*JustMainVoteConflict) BasicCheck

func (j *JustMainVoteConflict) BasicCheck() error

func (*JustMainVoteConflict) Type

type JustMainVoteConflictV2

type JustMainVoteConflictV2 struct {
	Just1 Just
	Just2 Just
}

type JustMainVoteNoConflict

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

func (*JustMainVoteNoConflict) BasicCheck

func (j *JustMainVoteNoConflict) BasicCheck() error

func (*JustMainVoteNoConflict) Type

type JustPreVoteHard

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

func (*JustPreVoteHard) BasicCheck

func (j *JustPreVoteHard) BasicCheck() error

func (*JustPreVoteHard) Type

func (*JustPreVoteHard) Type() JustType

type JustPreVoteSoft

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

func (*JustPreVoteSoft) BasicCheck

func (j *JustPreVoteSoft) BasicCheck() error

func (*JustPreVoteSoft) Type

func (*JustPreVoteSoft) Type() JustType

type JustType

type JustType uint8

func (JustType) String

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

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

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

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

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

NewPrecommitVote creates a new PRECOMMIT with the specified parameters.

func NewPrepareVote

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

NewPrepareVote creates a new PREPARE with the specified parameters. Deprecated: Prevote step is removed in the new consensus algorithm.

func (*Vote) BasicCheck

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

func (v *Vote) CPJust() Just

CPJust returns the change proposer justification for the vote.

func (*Vote) CPRound

func (v *Vote) CPRound() int16

CPRound returns the change proposer round the vote.

func (*Vote) CPValue

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

func (v *Vote) IsCPVote() bool

func (*Vote) MarshalCBOR

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

MarshalCBOR encodes 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

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 decodes 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