Documentation ¶
Index ¶
- Variables
- type Broadcast
- type FinalizedProposal
- type Message
- type Node
- type Option
- type Signer
- type Tendermint
- func (t *Tendermint) AddPrecommitMessage(message *types.PrecommitMessage) error
- func (t *Tendermint) AddPrevoteMessage(message *types.PrevoteMessage) error
- func (t *Tendermint) AddProposalMessage(message *types.ProposalMessage) error
- func (t *Tendermint) RunSequence(ctx context.Context, h uint64) *FinalizedProposal
- type Timeout
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidMessageSignature = errors.New("invalid message signature") ErrMessageFromNonValidator = errors.New("message is from a non-validator") ErrEarlierHeightMessage = errors.New("message is for an earlier height") ErrEarlierRoundMessage = errors.New("message is for an earlier round") )
Functions ¶
This section is empty.
Types ¶
type Broadcast ¶
type Broadcast interface { // BroadcastPropose broadcasts a PROPOSAL message BroadcastPropose(message *types.ProposalMessage) // BroadcastPrevote broadcasts a PREVOTE message BroadcastPrevote(message *types.PrevoteMessage) // BroadcastPrecommit broadcasts a PRECOMMIT message BroadcastPrecommit(message *types.PrecommitMessage) }
Broadcast is an abstraction over the networking / message sharing interface that enables message passing between validators
type FinalizedProposal ¶
type FinalizedProposal struct { Data []byte // the raw proposal data, accepted proposal ID []byte // the ID of the proposal (usually hash) }
FinalizedProposal is the finalized proposal wrapper, that contains the raw proposal data, and the ID of the data (usually hash)
type Message ¶
type Message interface { // GetView fetches the message view GetView() *types.View // GetSender fetches the message sender GetSender() []byte // GetSignature fetches the message signature GetSignature() []byte // GetSignaturePayload fetches the signature payload (sign data) GetSignaturePayload() []byte // Verify verifies the message content is valid (base verification) Verify() error }
Message is the content being passed around between consensus validators. Message types: PROPOSAL, PREVOTE, PRECOMMIT
type Node ¶
type Node interface { // ID returns the ID associated with the current process (validator) ID() []byte // Hash generates a hash of the given data. // It must not modify the slice proposal, even temporarily // and must not retain the data Hash(proposal []byte) []byte // BuildProposal generates a raw proposal for the given height BuildProposal(height uint64) []byte }
Node interface is an abstraction over a single entity (current process) that runs the consensus algorithm
type Option ¶
type Option func(t *Tendermint)
func WithLogger ¶
WithLogger specifies the logger for the Tendermint consensus engine
func WithPrecommitTimeout ¶
WithPrecommitTimeout specifies the precommit state timeout
func WithPrevoteTimeout ¶
WithPrevoteTimeout specifies the prevote state timeout
func WithProposeTimeout ¶
WithProposeTimeout specifies the propose state timeout
type Signer ¶
type Signer interface { // Sign generates a signature for the given raw data Sign(data []byte) []byte // IsValidSignature verifies whether the signature matches the raw data IsValidSignature(data []byte, signature []byte) bool }
Signer is an abstraction over the signature manipulation process
type Tendermint ¶
type Tendermint struct {
// contains filtered or unexported fields
}
Tendermint is the single consensus engine instance
func NewTendermint ¶
func NewTendermint( verifier Verifier, node Node, broadcast Broadcast, signer Signer, opts ...Option, ) *Tendermint
NewTendermint creates a new instance of the Tendermint consensus engine
func (*Tendermint) AddPrecommitMessage ¶
func (t *Tendermint) AddPrecommitMessage(message *types.PrecommitMessage) error
AddPrecommitMessage verifies and adds a new precommit message to the consensus engine
func (*Tendermint) AddPrevoteMessage ¶
func (t *Tendermint) AddPrevoteMessage(message *types.PrevoteMessage) error
AddPrevoteMessage verifies and adds a new prevote message to the consensus engine
func (*Tendermint) AddProposalMessage ¶
func (t *Tendermint) AddProposalMessage(message *types.ProposalMessage) error
AddProposalMessage verifies and adds a new proposal message to the consensus engine
func (*Tendermint) RunSequence ¶
func (t *Tendermint) RunSequence(ctx context.Context, h uint64) *FinalizedProposal
RunSequence runs the Tendermint consensus sequence for a given height, returning only when a proposal has been finalized (consensus reached), or the context has been cancelled
type Timeout ¶
type Timeout struct { Initial time.Duration // the initial timeout duration Delta time.Duration // the delta for future timeouts }
Timeout is a holder for timeout duration information (constant)
type Verifier ¶
type Verifier interface { // IsProposer checks if the given ID matches the proposer for the given height IsProposer(id []byte, height uint64, round uint64) bool // IsValidator checks if the given message sender ID belongs to a validator IsValidator(id []byte) bool // IsValidProposal checks if the given proposal is valid, for the given height IsValidProposal(proposal []byte, height uint64) bool // GetSumVotingPower returns the summed voting power from // the given unique message authors GetSumVotingPower(msgs []Message) uint64 // GetTotalVotingPower returns the total voting power // of the entire validator set for the given height GetTotalVotingPower(height uint64) uint64 }
Verifier is an abstraction over the outer consensus calling context that has access to validator set information