clock

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		AcceptedTimeUpdated:  event.New1[time.Time](),
		ConfirmedTimeUpdated: event.New1[time.Time](),
	}
})

NewEvents is the constructor of the Events object.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Accepted returns a notion of time that is anchored to the latest accepted block.
	Accepted() RelativeTime

	Confirmed() RelativeTime

	// Snapshot returns a snapshot of all time values tracked in the clock read atomically.
	Snapshot() *Snapshot

	// Reset resets the time values tracked in the clock to the given time.
	Reset(newTime time.Time)

	// Interface embeds the required methods of the module.Interface.
	module.Interface
}

Clock is an engine module that provides different notions of time according to the different levels of finality.

type Events

type Events struct {
	// AcceptedTimeUpdated is triggered when the accepted time is updated.
	AcceptedTimeUpdated *event.Event1[time.Time]
	// ConfirmedTimeUpdated is triggered when the confirmed time is updated.
	ConfirmedTimeUpdated *event.Event1[time.Time]

	// Group is trait that makes the dictionary linkable.
	event.Group[Events, *Events]
}

Events contains a dictionary of events that are triggered by the Clock.

type RelativeTime

type RelativeTime interface {
	// Time returns the original time value.
	Time() time.Time

	// RelativeTime returns the time value after it has advanced with the system clock.
	RelativeTime() time.Time
}

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

type Snapshot

type Snapshot struct {
	AcceptedTime          time.Time
	RelativeAcceptedTime  time.Time
	ConfirmedTime         time.Time
	RelativeConfirmedTime time.Time
}

Snapshot contains the snapshot of all time values tracked in the clock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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