blocktime

package
v1.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider(opts ...options.Option[Clock]) module.Provider[*engine.Engine, clock.Clock]

NewProvider creates a new Clock provider with the given options.

Types

type Clock

type Clock struct {
	syncutils.RWMutex

	// Module embeds the required methods of the module.Interface.
	module.Module
	// contains filtered or unexported fields
}

Clock implements the clock.Clock interface that sources its notion of time from accepted and confirmed blocks.

func (*Clock) Accepted

func (c *Clock) Accepted() clock.RelativeTime

Accepted returns a notion of time that is anchored to the latest accepted block.

func (*Clock) Confirmed

func (c *Clock) Confirmed() clock.RelativeTime

Confirmed returns a notion of time that is anchored to the latest confirmed block.

func (*Clock) Reset

func (c *Clock) Reset(newTime time.Time)

Reset resets the time values tracked in the clock to the given time.

func (*Clock) Shutdown

func (c *Clock) Shutdown()

func (*Clock) Snapshot

func (c *Clock) Snapshot() *clock.Snapshot

type RelativeTime

type RelativeTime struct {
	// OnUpdated is triggered when the time is updated.
	OnUpdated *event.Event1[time.Time]
	// contains filtered or unexported fields
}

RelativeTime is a time value that monotonically advances with the system clock.

func NewRelativeTime

func NewRelativeTime() *RelativeTime

NewRelativeTime creates a new RelativeTime.

func (*RelativeTime) Advance

func (c *RelativeTime) Advance(newTime time.Time) (updated bool)

Advance advances the time value if the given time is larger than the current time (maintaining monotonicity of the relative time).

func (*RelativeTime) RelativeTime

func (c *RelativeTime) RelativeTime() time.Time

RelativeTime returns the time value after it has advanced with the system clock.

func (*RelativeTime) Reset

func (c *RelativeTime) Reset(newTime time.Time)

Reset resets the time value to the given time (resetting monotonicity of the relative time).

func (*RelativeTime) Set

func (c *RelativeTime) Set(newTime time.Time) (updated bool)

Set sets the time value if the given time is larger than the current time (resetting monotonicity of the relative time).

func (*RelativeTime) Time

func (c *RelativeTime) Time() time.Time

Time returns the original time value.

Jump to

Keyboard shortcuts

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