cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.SlotConfig

Description

Convert between slots and Unix milliseconds within a period of constant slot duration. A configuration applies from its reference slot onwards; it does not describe earlier eras or predict future changes in slot duration.

import qualified Cometa.SlotConfig as Slots

firstMillisecond = Slots.slotToTime Slots.preview 100
enclosingSlot = firstMillisecond >>= Slots.timeToSlot Slots.preview
Synopsis

Documentation

data SlotConfig Source #

A reference slot, its Unix start time, and a positive slot duration. Equality compares these three values.

Instances

Instances details
Show SlotConfig Source # 
Instance details

Defined in Cometa.SlotConfig

Eq SlotConfig Source # 
Instance details

Defined in Cometa.SlotConfig

mkSlotConfig Source #

Arguments

:: Word64

Unix start time of the reference slot, in milliseconds.

-> Word64

Reference slot number.

-> Word64

Duration of one slot, in milliseconds; must be positive.

-> Either Error SlotConfig 

Construct a constant-duration schedule. A zero duration is rejected.

zeroTime :: SlotConfig -> Word64 Source #

Unix start time of the reference slot, in milliseconds.

zeroSlot :: SlotConfig -> Word64 Source #

First slot described by this configuration.

slotLength :: SlotConfig -> Word64 Source #

Positive duration of each slot, in milliseconds.

mainnet :: SlotConfig Source #

Mainnet's one-second schedule starting at slot 4,492,800. Earlier Byron slots require a different configuration.

preview :: SlotConfig Source #

Preview's one-second schedule starting at slot zero.

preprod :: SlotConfig Source #

Preprod's one-second schedule starting at slot 86,400.

slotToTime :: SlotConfig -> Word64 -> Either Error Word64 Source #

Return the Unix start time of a slot, in milliseconds. Slots before the reference slot and times greater than 2^64 - 1 are rejected.

timeToSlot :: SlotConfig -> Word64 -> Either Error Word64 Source #

Return the slot containing a Unix timestamp in milliseconds. A slot includes its start instant and excludes the next slot's start. Times before the reference time and resulting slots greater than 2^64 - 1 are rejected.