Documentation
¶
Overview ¶
Package state contains the interface TransitionBuffer and its implementation
Note: TransitionBuffer is not thread safe
`Dequeue` will return the most relevant `Proposed` transition for the given `Height`.
Index ¶
- Constants
- func NewTimer(numTicksToExpiry int) timer
- type Action
- type Commit
- type Machine
- type PreCommitted
- type PreVoted
- type Propose
- type Proposed
- type SignedPreCommit
- type SignedPreVote
- type State
- type Ticked
- type Transition
- type TransitionBuffer
- type WaitingForCommit
- type WaitingForPolka
- type WaitingForPropose
Constants ¶
const NumTicksToTriggerTimeOut = 2
NumTicksToTriggerTimeOut specifies the maximum number of Ticks to wait before triggering a TimedOut transition.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action interface {
// IsAction is a marker function. It is implemented by types to ensure that
// we cannot accidentally use the wrong types is some functions. We use type
// switching is used to enumerate the possible concrete types.
IsAction()
}
An Action is emitted by the state Machine to signal to other packages that some Action needs to be broadcast to other state Machines that are participating in the consensus algorithm.
type Commit ¶
type Machine ¶
type Machine interface {
// State returns the current state of the Machine. Generally, the Machine
// will be waiting for a Propose, waiting for a Polka, or waiting for a
// Commit.
State() State
// Height returns the current height on which the Machine is trying to reach
// consensus on a new Block.
Height() block.Height
// Round returns the current round in which the Machine is trying tp reach
// consensus on a new Block.
Round() block.Round
// LastBlock returns the last Block to which the Machine has committed. If
// no such Block exists, the genesis block is returned.
LastBlock() block.SignedBlock
// StartRound is called once when the StateMachine starts operating and
// everytime a round is completed. Actions returned by StartRound are
// expected to be dispatched to all other Replicas in the system. If the
// action returned by StartRound is not nil, it must be sent back to the
// same StateMachine for it to progress.
StartRound(round block.Round, commit *block.Commit) Action
// Commit the Machine to a Block that has already been committed to by the
// BFT replicated state machine.
Commit(commit block.Commit)
// Transition the Machine from one state to another. The state might not
// actually change, depending on the Transition and the current state of the
// Machine.
Transition(transition Transition) Action
}
A Machine is a deterministic state machine that is used to implement all states and transitions required to participate in a BFT replicated state machine using the Tendermint consensus algorithm. For more information, see https://arxiv.org/pdf/1807.04938.pdf.
type PreCommitted ¶
type PreCommitted struct {
block.SignedPreCommit
}
A PreCommitted polka has been signed and broadcast by another `Replica`.
func (PreCommitted) IsTransition ¶
func (PreCommitted) IsTransition()
IsTransition implements the `Transition` interface for the `PreCommitted` event.
func (PreCommitted) Round ¶
func (precommitted PreCommitted) Round() block.Round
Round implements the `Transition` interface for the `PreCommitted` event.
func (PreCommitted) Signer ¶
func (precommitted PreCommitted) Signer() sig.Signatory
Signer implements the `Transition` interface for the `PreCommitted` event.
type PreVoted ¶
type PreVoted struct {
block.SignedPreVote
}
A PreVoted block has been signed and broadcast by another `Replica`.
func (PreVoted) IsTransition ¶
func (PreVoted) IsTransition()
IsTransition implements the `Transition` interface for the `PreVoted` event.
type Propose ¶
type Propose struct {
block.SignedPropose
LastCommit Commit
}
Propose a Block for consensus in the current round. A previously found Commit can be included to help locked state Machines to unlock.
type Proposed ¶
type Proposed struct {
block.SignedPropose
}
A Proposed block has been received by another Replica.
func (Proposed) IsTransition ¶
func (Proposed) IsTransition()
IsTransition implements the `Transition` interface for the `Proposed` event.
type SignedPreCommit ¶
type SignedPreCommit struct {
block.SignedPreCommit
}
func (SignedPreCommit) IsAction ¶
func (SignedPreCommit) IsAction()
IsAction is a marker function that implements the Action interface for the SignedPreCommit type.
type SignedPreVote ¶
type SignedPreVote struct {
block.SignedPreVote
}
func (SignedPreVote) IsAction ¶
func (SignedPreVote) IsAction()
IsAction is a marker function that implements the Action interface for the SignedPreVote type.
type Ticked ¶
An external event has triggered a Tick.
func (Ticked) IsTransition ¶
func (Ticked) IsTransition()
IsTransition implements the `Transition` interface for the `Ticked` event.
type Transition ¶
A Transition is an event that transitions a `Machine` from one State to another. It is generated externally to the `Machine`.
type TransitionBuffer ¶
type TransitionBuffer interface {
Enqueue(transition Transition)
Dequeue(height block.Height) (Transition, bool)
// Drop everything below the given Height. You should call this
// the moment you know everything below the current height is
// meaningless.
Drop(height block.Height)
}
A TransitionBuffer is used to temporarily buffer `Proposed` that are not ready to be processed because they are from higher rounds. All `Transitions` are buffered against their respective `Height` and will be dequeued one by one.
func NewTransitionBuffer ¶
func NewTransitionBuffer(cap int) TransitionBuffer
NewTransitionBuffer creates an empty TransitionBuffer with a maximum queue capacity.
type WaitingForCommit ¶
type WaitingForCommit struct {
}
func (WaitingForCommit) IsState ¶
func (WaitingForCommit) IsState()
type WaitingForPolka ¶
type WaitingForPolka struct {
}
func (WaitingForPolka) IsState ¶
func (WaitingForPolka) IsState()
type WaitingForPropose ¶
type WaitingForPropose struct {
}
func (WaitingForPropose) IsState ¶
func (WaitingForPropose) IsState()