Documentation ¶
Index ¶
- type RoundTimer
- type StandardRoundTimer
- func (t *StandardRoundTimer) CommitWaitTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
- func (t *StandardRoundTimer) PrecommitDelayTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
- func (t *StandardRoundTimer) PrevoteDelayTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
- func (t *StandardRoundTimer) ProposalTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
- func (t *StandardRoundTimer) Wait()
- type StateMachine
- type StateMachineConfig
- type TimeoutStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RoundTimer ¶
type RoundTimer interface { ProposalTimer(ctx context.Context, height uint64, round uint32) (ch <-chan struct{}, cancel func()) PrevoteDelayTimer(ctx context.Context, height uint64, round uint32) (ch <-chan struct{}, cancel func()) PrecommitDelayTimer(ctx context.Context, height uint64, round uint32) (ch <-chan struct{}, cancel func()) CommitWaitTimer(ctx context.Context, height uint64, round uint32) (ch <-chan struct{}, cancel func()) }
RoundTimer is the interface the state machine uses to manage timeouts per step. While using a time.Timer directly would be simpler, that would pose difficulty in fine-grained management of timers during tests. So instead, the RoundTimer offers a set of methods that return a channel that will close upon a timeout, and an associated cancel function that must be called to release resources. It is safe to call the cancel function multiple times, and concurrently, if needed.
Note that calling the cancel function will not close the returned channel, as to avoid spuriously indicating a timer has elapsed.
The context argument is used only for communicating with any coordination goroutines; it has no bearing on when the returned channel is closed. If the context is cancelled while attempting to get a timer, the returned channel is nil and the returned cancel function is a no-op non-nil function.
type StandardRoundTimer ¶
type StandardRoundTimer struct {
// contains filtered or unexported fields
}
StandardRoundTimer is the default implementation of RoundTimer, backed by actual time.Timer instances.
func NewStandardRoundTimer ¶
func NewStandardRoundTimer(ctx context.Context, s TimeoutStrategy) *StandardRoundTimer
func (*StandardRoundTimer) CommitWaitTimer ¶
func (t *StandardRoundTimer) CommitWaitTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
func (*StandardRoundTimer) PrecommitDelayTimer ¶
func (t *StandardRoundTimer) PrecommitDelayTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
func (*StandardRoundTimer) PrevoteDelayTimer ¶
func (t *StandardRoundTimer) PrevoteDelayTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
func (*StandardRoundTimer) ProposalTimer ¶
func (t *StandardRoundTimer) ProposalTimer(ctx context.Context, height uint64, round uint32) (<-chan struct{}, func())
func (*StandardRoundTimer) Wait ¶
func (t *StandardRoundTimer) Wait()
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
func NewStateMachine ¶
func NewStateMachine(ctx context.Context, log *slog.Logger, cfg StateMachineConfig) (*StateMachine, error)
func (*StateMachine) Wait ¶
func (m *StateMachine) Wait()
type StateMachineConfig ¶
type StateMachineConfig struct { Signer tmconsensus.Signer HashScheme tmconsensus.HashScheme Genesis tmconsensus.Genesis ActionStore tmstore.ActionStore FinalizationStore tmstore.FinalizationStore StateMachineStore tmstore.StateMachineStore RoundTimer RoundTimer ConsensusStrategy tmconsensus.ConsensusStrategy RoundViewInCh <-chan tmeil.StateMachineRoundView RoundEntranceOutCh chan<- tmeil.StateMachineRoundEntrance BlockDataArrivalCh <-chan tmelink.BlockDataArrival FinalizeBlockRequestCh chan<- tmdriver.FinalizeBlockRequest MetricsCollector *tmemetrics.Collector Watchdog *gwatchdog.Watchdog AssertEnv gassert.Env }
type TimeoutStrategy ¶
type TimeoutStrategy interface { ProposalTimeout(height uint64, round uint32) time.Duration PrevoteDelayTimeout(height uint64, round uint32) time.Duration PrecommitDelayTimeout(height uint64, round uint32) time.Duration CommitWaitTimeout(height uint64, round uint32) time.Duration }
TimeoutStrategy defines how to calculate the timeout durations for a StandardRoundTimer.