| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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
- data SlotConfig
- mkSlotConfig :: Word64 -> Word64 -> Word64 -> Either Error SlotConfig
- zeroTime :: SlotConfig -> Word64
- zeroSlot :: SlotConfig -> Word64
- slotLength :: SlotConfig -> Word64
- mainnet :: SlotConfig
- preview :: SlotConfig
- preprod :: SlotConfig
- slotToTime :: SlotConfig -> Word64 -> Either Error Word64
- timeToSlot :: SlotConfig -> Word64 -> Either Error Word64
Documentation
data SlotConfig Source #
A reference slot, its Unix start time, and a positive slot duration. Equality compares these three values.
Instances
| Show SlotConfig Source # | |
Defined in Cometa.SlotConfig Methods showsPrec :: Int -> SlotConfig -> ShowS # show :: SlotConfig -> String # showList :: [SlotConfig] -> ShowS # | |
| Eq SlotConfig Source # | |
Defined in Cometa.SlotConfig | |
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.