message

package
v0.0.0-...-5104f13 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsVoteTypeValid

func IsVoteTypeValid(t VoteType) bool

IsVoteTypeValid returns true if t is a valid vote type.

func RegisterConsensusMessages

func RegisterConsensusMessages(cdc *amino.Codec)

Types

type AppState

type AppState struct {
	// The first height that reaches bft consensus is 1, so LastHeight
	// should be 0 at genesis
	LastHeight       int64
	LastProposedData ProposedData
	LastCommitTime   time.Time

	// the latest AppHash we've received from calling abci.Commit()
	AppHash []byte
}

type Commit

type Commit struct {
	ProposedData ProposedData `json:"proposed_data"`
	Prev         ProposedData `json:"prev"`
	Precommits   []*Vote      `json:"precommits"`
	CommitTime   time.Time    `json:"committime"`
	Address      PubKey       `json:"address"`
	Signature    []byte       `json:"signature"`
}

Commit contains the evidence that a block was committed by a set of validators.

func (*Commit) Bytes

func (commit *Commit) Bytes() []byte

func (*Commit) Digest

func (commit *Commit) Digest() []byte

func (*Commit) FirstPrecommit

func (commit *Commit) FirstPrecommit() *Vote

FirstPrecommit returns the first non-nil precommit in the commit. If all precommits are nil, it returns an empty precommit with height 0.

func (*Commit) GetByIndex

func (commit *Commit) GetByIndex(index int) *Vote

GetByIndex returns the vote corresponding to a given validator index

func (*Commit) GetSignature

func (commit *Commit) GetSignature() []byte

func (*Commit) GetSigner

func (commit *Commit) GetSigner() PubKey

func (*Commit) Height

func (commit *Commit) Height() int64

Height returns the height of the commit

func (*Commit) IsCommit

func (commit *Commit) IsCommit() bool

IsCommit returns true if there is at least one vote

func (*Commit) Round

func (commit *Commit) Round() int

Round returns the round of the commit

func (*Commit) SetSignature

func (commit *Commit) SetSignature(sig []byte)

func (*Commit) SetSigner

func (commit *Commit) SetSigner(key PubKey)

func (*Commit) Size

func (commit *Commit) Size() int

Size returns the number of votes in the commit

func (*Commit) String

func (commit *Commit) String() string

func (*Commit) Type

func (commit *Commit) Type() byte

Type returns the vote type of the commit, which is always VoteTypePrecommit

func (*Commit) ValidateBasic

func (commit *Commit) ValidateBasic() error

ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.

type ConsensusMessage

type ConsensusMessage interface {
	ValidateBasic() error
	Digest() []byte
	SetSigner(key PubKey)
	SetSignature(sig []byte)
	GetSigner() PubKey
	GetSignature() []byte
	Bytes() []byte
	String() string
}

ConsensusMessage is a message that can be sent and received on the ConsensusReactor

func DecodeConsensusMsg

func DecodeConsensusMsg(bz []byte) (msg ConsensusMessage, err error)

type FetchVotesReq

type FetchVotesReq struct {
	Type   VoteType `json:"type"`
	Height int64    `json:"height"`
	Round  int      `json:"round"`
	// Invoker indicates who wants the votes
	Invoker PubKey `json:"invoker"`
	// Voters indicates the validators from whom @Invoker currently receive vote
	Voters    []PubKey  `json:"voters"`
	Time      time.Time `json:"time"`
	Signature []byte    `json:"signature"`
}

func (*FetchVotesReq) Bytes

func (fvr *FetchVotesReq) Bytes() []byte

func (*FetchVotesReq) Digest

func (fvr *FetchVotesReq) Digest() []byte

func (*FetchVotesReq) GetSignature

func (fvr *FetchVotesReq) GetSignature() []byte

func (*FetchVotesReq) GetSigner

func (fvr *FetchVotesReq) GetSigner() PubKey

func (*FetchVotesReq) SetSignature

func (fvr *FetchVotesReq) SetSignature(sig []byte)

func (*FetchVotesReq) SetSigner

func (fvr *FetchVotesReq) SetSigner(key PubKey)

func (*FetchVotesReq) String

func (fvr *FetchVotesReq) String() string

func (*FetchVotesReq) ValidateBasic

func (fvr *FetchVotesReq) ValidateBasic() error

ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.

type FetchVotesRsp

type FetchVotesRsp struct {
	Type         VoteType  `json:"type"`
	Height       int64     `json:"height"`
	Round        int       `json:"round"`
	Responser    PubKey    `json:"responser"`
	MissingVotes []*Vote   `json:"missing_votes"`
	Time         time.Time `json:"time"`
	Signature    []byte    `json:"signature"`
}

func (*FetchVotesRsp) Bytes

func (fvr *FetchVotesRsp) Bytes() []byte

func (*FetchVotesRsp) Digest

func (fvr *FetchVotesRsp) Digest() []byte

func (*FetchVotesRsp) GetSignature

func (fvr *FetchVotesRsp) GetSignature() []byte

func (*FetchVotesRsp) GetSigner

func (fvr *FetchVotesRsp) GetSigner() PubKey

func (*FetchVotesRsp) SetSignature

func (fvr *FetchVotesRsp) SetSignature(sig []byte)

func (*FetchVotesRsp) SetSigner

func (fvr *FetchVotesRsp) SetSigner(key PubKey)

func (*FetchVotesRsp) String

func (fvr *FetchVotesRsp) String() string

func (*FetchVotesRsp) ValidateBasic

func (fvr *FetchVotesRsp) ValidateBasic() error

ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.

type ProposedData

type ProposedData [32]byte
var NilData ProposedData

func (ProposedData) IsNil

func (pd ProposedData) IsNil() bool

type PubKey

type PubKey string

PubKey is string representation of the public key

type Vote

type Vote struct {
	Type      VoteType     `json:"type"`
	Height    int64        `json:"height"`
	Round     int          `json:"round"`
	Timestamp time.Time    `json:"timestamp"`
	Proposed  ProposedData `json:"proposed_data"` // zero if vote is nil.
	Prev      ProposedData `json:"prev"`
	Address   PubKey       `json:"pub_key"`
	Signature []byte       `json:"signature"`
}

Vote represents a prevote, precommit from validators for consensus.

func NewVote

func NewVote(t VoteType, height int64, round int, proposed *ProposedData, prev *ProposedData) *Vote

func (*Vote) Bytes

func (vote *Vote) Bytes() []byte

func (*Vote) Copy

func (v *Vote) Copy() *Vote

func (*Vote) Digest

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

func (*Vote) GetSignature

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

func (*Vote) GetSigner

func (v *Vote) GetSigner() PubKey

func (*Vote) SetSignature

func (v *Vote) SetSignature(sig []byte)

func (*Vote) SetSigner

func (v *Vote) SetSigner(key PubKey)

func (*Vote) String

func (vote *Vote) String() string

func (*Vote) ValidateBasic

func (vote *Vote) ValidateBasic() error

ValidateBasic performs basic validation.

type VoteType

type VoteType byte

VoteType is a type of signed message in the consensus.

const (
	// Votes
	PrevoteType   VoteType = 0x01
	PrecommitType VoteType = 0x02

	// Proposals
	ProposalType VoteType = 0x20
)

Jump to

Keyboard shortcuts

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