Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index int64
Index is the ID of a slot.
type IndexedEntity ¶
type IndexedEntity[IDType IndexedID] interface { ID() IDType }
type IndexedID ¶
type IndexedID interface { comparable Index() Index String() string }
type TimeProvider ¶
type TimeProvider struct {
// contains filtered or unexported fields
}
TimeProvider defines the genesis time of slot 0 and allows to convert index to and from time.
func NewTimeProvider ¶
func NewTimeProvider(genesisUnixTime int64, slotDuration int64) *TimeProvider
NewTimeProvider creates a new time provider.
func (*TimeProvider) Duration ¶
func (t *TimeProvider) Duration() int64
Duration is the slot duration in seconds.
func (*TimeProvider) EndTime ¶
func (t *TimeProvider) EndTime(i Index) time.Time
EndTime returns the latest possible timestamp for a slot. Anything with higher timestamp will belong to the next slot.
func (*TimeProvider) GenesisTime ¶
func (t *TimeProvider) GenesisTime() time.Time
GenesisTime is the time of the genesis.
func (*TimeProvider) GenesisUnixTime ¶
func (t *TimeProvider) GenesisUnixTime() int64
GenesisUnixTime is the time (Unix in seconds) of the genesis.
func (*TimeProvider) IndexFromTime ¶
func (t *TimeProvider) IndexFromTime(time time.Time) Index
IndexFromTime calculates the Index from the given time.
Note: slots are counted starting from 1 because 0 is reserved for the genesis which has to be addressable as its own slot as part of the commitment chains.