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
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
CurrentLayer gets the current layer.
func (*NodeClock) GenesisTime ¶ added in v1.0.0
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