Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- data GYSlotConfig
- data GYEraSlotConfig
- makeSlotConfig ∷ SystemStart → EraHistory → Either String GYSlotConfig
- simpleSlotConfig ∷ UTCTime → NominalDiffTime → GYSlotConfig
- slotToBeginTimePure ∷ GYSlotConfig → GYSlot → GYTime
- slotToEndTimePure ∷ GYSlotConfig → GYSlot → GYTime
- enclosingSlotFromTimePure ∷ GYSlotConfig → GYTime → Maybe GYSlot
- unsafeEnclosingSlotFromTimePure ∷ GYSlotConfig → GYTime → GYSlot
Documentation
data GYSlotConfig #
Slot config for each era, alongside the absolute system start time.
Invariants ==
- List must be ordered on era, with earliest era first, and current era last.
- Each era element must be continuous.
i.e for [x, y], the slot start of y must be the end slot of x (see EraHistory
).
- The final era element must be the current era, and it is _assumed_ that its end is unbounded (realistic).
Instances
Show GYSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig showsPrec ∷ Int → GYSlotConfig → ShowS # show ∷ GYSlotConfig → String # showList ∷ [GYSlotConfig] → ShowS # | |
Eq GYSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig (==) ∷ GYSlotConfig → GYSlotConfig → Bool # (/=) ∷ GYSlotConfig → GYSlotConfig → Bool # |
data GYEraSlotConfig #
Information about slot config for a particular ledger era.
Instances
Show GYEraSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig showsPrec ∷ Int → GYEraSlotConfig → ShowS # show ∷ GYEraSlotConfig → String # showList ∷ [GYEraSlotConfig] → ShowS # | |
Eq GYEraSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig (==) ∷ GYEraSlotConfig → GYEraSlotConfig → Bool # (/=) ∷ GYEraSlotConfig → GYEraSlotConfig → Bool # |
makeSlotConfig ∷ SystemStart → EraHistory → Either String GYSlotConfig #
Create a GYSlotConfig
from the system start and the cardano era history.
This is the recommended, robust, way to create slot config.
simpleSlotConfig ∷ UTCTime → NominalDiffTime → GYSlotConfig #
Create a single era slot config (useful for emulator traces).
DO NOT USE for testnets/mainnet. Please use makeSlotConfig
instead.
slotToBeginTimePure ∷ GYSlotConfig → GYSlot → GYTime #
Get the starting GYTime
of a GYSlot
given a GYSlotConfig
.
>>>
slotToBeginTimePure (simpleSlotConfig (Time.posixSecondsToUTCTime 10) 2) (unsafeSlotFromInteger 1)
GYTime 12s
slotToEndTimePure ∷ GYSlotConfig → GYSlot → GYTime #
Get the ending GYTime
of a GYSlot
(inclusive) given a GYSlotConfig
.
>>>
slotToEndTimePure (simpleSlotConfig (Time.posixSecondsToUTCTime 10) 2) (unsafeSlotFromInteger 1)
GYTime 13.999s
enclosingSlotFromTimePure ∷ GYSlotConfig → GYTime → Maybe GYSlot #
Get the GYSlot
of a GYTime
given a GYSlotConfig
.
Returns Nothing
if given time is before known system start.
>>>
enclosingSlotFromTimePure (simpleSlotConfig (Time.posixSecondsToUTCTime 10) 2) (timeFromPOSIX 12)
Just (GYSlot 1)
>>>
enclosingSlotFromTimePure (simpleSlotConfig (Time.posixSecondsToUTCTime 10) 2) (timeFromPOSIX 14)
Just (GYSlot 2)
unsafeEnclosingSlotFromTimePure ∷ GYSlotConfig → GYTime → GYSlot #
Partial version of enclosingSlotFromTimePure
.