| Copyright | (c) 2023 GYELD GMBH |
|---|---|
| License | Apache 2.0 |
| Maintainer | support@geniusyield.co |
| Stability | develop |
| Safe Haskell | None |
| Language | Haskell2010 |
GeniusYield.Types.SlotConfig
Description
Synopsis
- data GYSlotConfig
- data GYEraSlotConfig
- makeSlotConfig ∷ SystemStart → EraHistory CardanoMode → 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
| Eq GYSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig | |
| Show GYSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig Methods showsPrec ∷ Int → GYSlotConfig → ShowS # show ∷ GYSlotConfig → String # showList ∷ [GYSlotConfig] → ShowS # | |
data GYEraSlotConfig #
Information about slot config for a particular ledger era.
Instances
| Eq GYEraSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig Methods (==) ∷ GYEraSlotConfig → GYEraSlotConfig → Bool # (/=) ∷ GYEraSlotConfig → GYEraSlotConfig → Bool # | |
| Show GYEraSlotConfig # | |
Defined in GeniusYield.Types.SlotConfig Methods showsPrec ∷ Int → GYEraSlotConfig → ShowS # show ∷ GYEraSlotConfig → String # showList ∷ [GYEraSlotConfig] → ShowS # | |
makeSlotConfig ∷ SystemStart → EraHistory CardanoMode → 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.