timer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the timeout in seconds set by default
	DefaultTimeout = 20 * time.Second

	// DefaultTimeoutScaling is the timeout scaling factor set by default
	DefaultTimeoutScaling = 0.5
)

Variables

This section is empty.

Functions

func NewLinearTimer

func NewLinearTimer(opts Options, handleTimeoutPropose, handleTimeoutPrevote, handleTimeoutPrecommit func(Timeout)) process.Timer

NewLinearTimer constructs a new Linear Timer from the input options and channels

Types

type LinearTimer

type LinearTimer struct {
	// contains filtered or unexported fields
}

LinearTimer defines a timer that implements a timing out functionality. The timeouts for different contexts (Propose, Prevote and Precommit) are provided as callback functions that handle the corresponding timeouts. The timeout scales linearly with the consensus round

func (*LinearTimer) TimeoutPrecommit

func (t *LinearTimer) TimeoutPrecommit(height process.Height, round process.Round)

TimeoutPrecommit schedules a precommit timeout with a timeout period appropriately calculated for the consensus height and round

func (*LinearTimer) TimeoutPrevote

func (t *LinearTimer) TimeoutPrevote(height process.Height, round process.Round)

TimeoutPrevote schedules a prevote timeout with a timeout period appropriately calculated for the consensus height and round

func (*LinearTimer) TimeoutPropose

func (t *LinearTimer) TimeoutPropose(height process.Height, round process.Round)

TimeoutPropose schedules a propose timeout with a timeout period appropriately calculated for the consensus height and round

type Options

type Options struct {
	Logger         *zap.Logger
	Timeout        time.Duration
	TimeoutScaling float64
}

Options represent the options for a Linear Timer

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options for a Linear Timer

func (Options) WithLogger added in v0.4.1

func (opts Options) WithLogger(logger *zap.Logger) Options

WithLogger updates the logger used in the Linear Timer

func (Options) WithTimeout

func (opts Options) WithTimeout(timeout time.Duration) Options

WithTimeout updates the timeout of the Linear Timer

func (Options) WithTimeoutScaling

func (opts Options) WithTimeoutScaling(timeoutScaling float64) Options

WithTimeoutScaling updates the timeout scaling factor of the Linear Timer

type Timeout

type Timeout struct {
	MessageType process.MessageType
	Height      process.Height
	Round       process.Round
}

Timeout represents an event emitted by the Linear Timer whenever a scheduled timeout is triggered

func (Timeout) Marshal added in v0.4.1

func (timeout Timeout) Marshal(buf []byte, rem int) ([]byte, int, error)

Marshal implements surge Marshaler for Timeout

func (Timeout) SizeHint added in v0.4.1

func (timeout Timeout) SizeHint() int

SizeHint implements surge SizeHinter for Timeout

func (*Timeout) Unmarshal added in v0.4.1

func (timeout *Timeout) Unmarshal(buf []byte, rem int) ([]byte, int, error)

Unmarshal implements surge Unmarshaler for Timeout

Jump to

Keyboard shortcuts

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