tendermint

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr interface {
	~[20]byte | felt.Felt
}

type Application

type Application[V Hashable[H], H Hash] interface {
	// Value returns the value to the Tendermint consensus algorith which can be proposed to other validators.
	Value() V

	// Valid returns true if the provided value is valid according to the application context.
	Valid(V) bool
}

type Blockchain

type Blockchain[V Hashable[H], H Hash, A Addr] interface {
	// Height return the current blockchain height
	Height() height

	// Commit is called by Tendermint when a block has been decided on and can be committed to the DB.
	Commit(height, V, []Precommit[H, A])
}

type Broadcaster

type Broadcaster[M Message[V, H, A], V Hashable[H], H Hash, A Addr] interface {
	// Broadcast will broadcast the message to the whole validator set. The function should not be blocking.
	Broadcast(M)

	// SendMsg would send a message to a specific validator. This would be required for helping send resquest and
	// response message to help a specifc validator to catch up.
	SendMsg(A, M)
}

type Broadcasters

type Broadcasters[V Hashable[H], H Hash, A Addr] struct {
	ProposalBroadcaster  Broadcaster[Proposal[V, H, A], V, H, A]
	PrevoteBroadcaster   Broadcaster[Prevote[H, A], V, H, A]
	PrecommitBroadcaster Broadcaster[Precommit[H, A], V, H, A]
}

type Hash

type Hash interface {
	~[32]byte | felt.Felt
}

type Hashable

type Hashable[H Hash] interface {
	Hash() H
}

Hashable's Hash() is used as ID()

type Listener

type Listener[M Message[V, H, A], V Hashable[H], H Hash, A Addr] interface {
	// Listen would return consensus messages to Tendermint which are set by the validator set.
	Listen() <-chan M
}

type Listeners

type Listeners[V Hashable[H], H Hash, A Addr] struct {
	ProposalListener  Listener[Proposal[V, H, A], V, H, A]
	PrevoteListener   Listener[Prevote[H, A], V, H, A]
	PrecommitListener Listener[Precommit[H, A], V, H, A]
}

type Message

type Message[V Hashable[H], H Hash, A Addr] interface {
	Proposal[V, H, A] | Prevote[H, A] | Precommit[H, A]
}

type Precommit

type Precommit[H Hash, A Addr] Vote[H, A]

type Prevote

type Prevote[H Hash, A Addr] Vote[H, A]

type Proposal

type Proposal[V Hashable[H], H Hash, A Addr] struct {
	H          height
	R          round
	ValidRound round
	Value      *V

	Sender A
}

type Slasher

type Slasher[M Message[V, H, A], V Hashable[H], H Hash, A Addr] interface {
	// Equivocation informs the slasher that a validator has sent conflicting messages. Thus it can decide whether to
	// slash the validator and by how much.
	Equivocation(msgs ...M)
}

type Tendermint

type Tendermint[V Hashable[H], H Hash, A Addr] struct {
	// contains filtered or unexported fields
}

func New

func New[V Hashable[H], H Hash, A Addr](nodeAddr A, app Application[V, H], chain Blockchain[V, H, A], vals Validators[A],
	listeners Listeners[V, H, A], broadcasters Broadcasters[V, H, A], tmPropose, tmPrevote, tmPrecommit timeoutFn,
) *Tendermint[V, H, A]

func (*Tendermint[_, _, _]) OnTimeoutPrecommit

func (t *Tendermint[_, _, _]) OnTimeoutPrecommit(h height, r round)

func (*Tendermint[_, H, A]) OnTimeoutPrevote

func (t *Tendermint[_, H, A]) OnTimeoutPrevote(h height, r round)

func (*Tendermint[_, H, A]) OnTimeoutPropose

func (t *Tendermint[_, H, A]) OnTimeoutPropose(h height, r round)

func (*Tendermint[V, H, A]) Start

func (t *Tendermint[V, H, A]) Start()

func (*Tendermint[V, H, A]) Stop

func (t *Tendermint[V, H, A]) Stop()

type Validators

type Validators[A Addr] interface {
	// TotalVotingPower represents N which is required to calculate the thresholds.
	TotalVotingPower(height) votingPower

	// ValidatorVotingPower returns the voting power of the a single validator. This is also required to implement
	// various thresholds. The assumption is that a single validator cannot have voting power more than f.
	ValidatorVotingPower(A) votingPower

	// Proposer returns the proposer of the current round and height.
	Proposer(height, round) A
}

type Vote

type Vote[H Hash, A Addr] struct {
	H  height
	R  round
	ID *H

	Sender A
}

Jump to

Keyboard shortcuts

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