timesync

package
v1.7.9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LayerConverter

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

LayerConverter is a converter between time to layer ID struct.

func (LayerConverter) LayerToTime

func (lc LayerConverter) LayerToTime(id types.LayerID) time.Time

LayerToTime returns the time of the provided layer.

func (LayerConverter) TimeToLayer

func (lc LayerConverter) TimeToLayer(t time.Time) types.LayerID

TimeToLayer returns the layer of the provided time.

type NodeClock added in v1.0.0

type NodeClock struct {
	LayerConverter // layer conversions provider
	// contains filtered or unexported fields
}

NodeClock is the struct holding a real clock.

func NewClock

func NewClock(opts ...OptionFunc) (*NodeClock, error)

NewClock return TimeClock struct that notifies tickInterval has passed.

func (*NodeClock) AwaitLayer added in v1.0.0

func (t *NodeClock) AwaitLayer(layerID types.LayerID) <-chan struct{}

AwaitLayer returns a channel that will be signaled when layer id layerID was ticked by the clock, or if this layer has passed while sleeping. It does so by closing the returned channel.

func (*NodeClock) Close added in v1.0.0

func (t *NodeClock) Close()

Close closes the clock ticker.

func (*NodeClock) CurrentLayer added in v1.0.0

func (t *NodeClock) CurrentLayer() types.LayerID

CurrentLayer gets the current layer.

func (*NodeClock) GenesisTime added in v1.0.0

func (t *NodeClock) GenesisTime() time.Time

GenesisTime returns at which time this clock has started (used to calculate current tick).

type OptionFunc added in v1.0.0

type OptionFunc func(*option) error

func WithGenesisTime added in v1.0.0

func WithGenesisTime(genesis time.Time) OptionFunc

WithGenesisTime sets the genesis time for the NodeClock.

func WithLayerDuration added in v1.0.0

func WithLayerDuration(d time.Duration) OptionFunc

WithLayerDuration sets the layer duration for the NodeClock.

func WithLogger added in v1.0.0

func WithLogger(logger *zap.Logger) OptionFunc

WithLogger sets the logger for the NodeClock.

func WithTickInterval added in v1.0.0

func WithTickInterval(d time.Duration) OptionFunc

Directories

Path Synopsis
nolint
nolint
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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