| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Chain.Slotting
Synopsis
- newtype SlotNumber = SlotNumber {}
- newtype EpochNumber = EpochNumber {}
- addSlotCount ∷ SlotCount → SlotNumber → SlotNumber
- newtype EpochSlots = EpochSlots {}
- data EpochAndSlotCount = EpochAndSlotCount {}
- fromSlotNumber ∷ EpochSlots → SlotNumber → EpochAndSlotCount
- newtype SlotCount = SlotCount {}
- epochFirstSlot ∷ EpochSlots → EpochNumber → SlotNumber
- data WithEpochSlots a = WithEpochSlots {}
- toSlotNumber ∷ EpochSlots → EpochAndSlotCount → SlotNumber
- slotNumberEpoch ∷ EpochSlots → SlotNumber → EpochNumber
- isBootstrapEra ∷ EpochNumber → EpochNumber → Bool
Documentation
newtype SlotNumber Source #
SlotNumber is an absolute slot number from the beginning of time
SlotNumber is held in a Word64. Assuming a slot every 20 seconds, Word64
is sufficient for slot indices for 10^13 years.
Constructors
| SlotNumber | |
Fields | |
Instances
newtype EpochNumber Source #
Index of epoch.
Constructors
| EpochNumber | |
Fields | |
Instances
| ToJSON EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods toJSON ∷ EpochNumber → Value Source # toEncoding ∷ EpochNumber → Encoding Source # toJSONList ∷ [EpochNumber] → Value Source # toEncodingList ∷ [EpochNumber] → Encoding Source # omitField ∷ EpochNumber → Bool Source # | |||||
| FromCBOR EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber | |||||
| ToCBOR EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods toCBOR ∷ EpochNumber → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy EpochNumber → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [EpochNumber] → Size Source # | |||||
| DecCBOR EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber | |||||
| EncCBOR EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods | |||||
| NFData EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods rnf ∷ EpochNumber → () # | |||||
| Buildable EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods build ∷ EpochNumber → Builder Source # | |||||
| Data EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods gfoldl ∷ (∀ d b. Data d ⇒ c (d → b) → d → c b) → (∀ g. g → c g) → EpochNumber → c EpochNumber # gunfold ∷ (∀ b r. Data b ⇒ c (b → r) → c r) → (∀ r. r → c r) → Constr → c EpochNumber # toConstr ∷ EpochNumber → Constr # dataTypeOf ∷ EpochNumber → DataType # dataCast1 ∷ Typeable t ⇒ (∀ d. Data d ⇒ c (t d)) → Maybe (c EpochNumber) # dataCast2 ∷ Typeable t ⇒ (∀ d e. (Data d, Data e) ⇒ c (t d e)) → Maybe (c EpochNumber) # gmapT ∷ (∀ b. Data b ⇒ b → b) → EpochNumber → EpochNumber # gmapQl ∷ (r → r' → r) → r → (∀ d. Data d ⇒ d → r') → EpochNumber → r # gmapQr ∷ ∀ r r'. (r' → r → r) → r → (∀ d. Data d ⇒ d → r') → EpochNumber → r # gmapQ ∷ (∀ d. Data d ⇒ d → u) → EpochNumber → [u] # gmapQi ∷ Int → (∀ d. Data d ⇒ d → u) → EpochNumber → u # gmapM ∷ Monad m ⇒ (∀ d. Data d ⇒ d → m d) → EpochNumber → m EpochNumber # gmapMp ∷ MonadPlus m ⇒ (∀ d. Data d ⇒ d → m d) → EpochNumber → m EpochNumber # gmapMo ∷ MonadPlus m ⇒ (∀ d. Data d ⇒ d → m d) → EpochNumber → m EpochNumber # | |||||
| Bounded EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber | |||||
| Enum EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods succ ∷ EpochNumber → EpochNumber # pred ∷ EpochNumber → EpochNumber # toEnum ∷ Int → EpochNumber # fromEnum ∷ EpochNumber → Int # enumFrom ∷ EpochNumber → [EpochNumber] # enumFromThen ∷ EpochNumber → EpochNumber → [EpochNumber] # enumFromTo ∷ EpochNumber → EpochNumber → [EpochNumber] # enumFromThenTo ∷ EpochNumber → EpochNumber → EpochNumber → [EpochNumber] # | |||||
| Generic EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Associated Types
| |||||
| Ix EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods range ∷ (EpochNumber, EpochNumber) → [EpochNumber] # index ∷ (EpochNumber, EpochNumber) → EpochNumber → Int # unsafeIndex ∷ (EpochNumber, EpochNumber) → EpochNumber → Int # inRange ∷ (EpochNumber, EpochNumber) → EpochNumber → Bool # rangeSize ∷ (EpochNumber, EpochNumber) → Int # unsafeRangeSize ∷ (EpochNumber, EpochNumber) → Int # | |||||
| Num EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods (+) ∷ EpochNumber → EpochNumber → EpochNumber # (-) ∷ EpochNumber → EpochNumber → EpochNumber # (*) ∷ EpochNumber → EpochNumber → EpochNumber # negate ∷ EpochNumber → EpochNumber # abs ∷ EpochNumber → EpochNumber # | |||||
| Integral EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods quot ∷ EpochNumber → EpochNumber → EpochNumber # rem ∷ EpochNumber → EpochNumber → EpochNumber # div ∷ EpochNumber → EpochNumber → EpochNumber # mod ∷ EpochNumber → EpochNumber → EpochNumber # quotRem ∷ EpochNumber → EpochNumber → (EpochNumber, EpochNumber) # divMod ∷ EpochNumber → EpochNumber → (EpochNumber, EpochNumber) # toInteger ∷ EpochNumber → Integer # | |||||
| Real EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods | |||||
| Show EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods showsPrec ∷ Int → EpochNumber → ShowS # show ∷ EpochNumber → String # showList ∷ [EpochNumber] → ShowS # | |||||
| Eq EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber | |||||
| Ord EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods compare ∷ EpochNumber → EpochNumber → Ordering # (<) ∷ EpochNumber → EpochNumber → Bool # (<=) ∷ EpochNumber → EpochNumber → Bool # (>) ∷ EpochNumber → EpochNumber → Bool # (>=) ∷ EpochNumber → EpochNumber → Bool # max ∷ EpochNumber → EpochNumber → EpochNumber # min ∷ EpochNumber → EpochNumber → EpochNumber # | |||||
| NoThunks EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber | |||||
| MonadError SchemaError m ⇒ FromJSON m EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods fromJSON ∷ JSValue → m EpochNumber Source # | |||||
| Monad m ⇒ ToJSON m EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber Methods toJSON ∷ EpochNumber → m JSValue Source # | |||||
| type Rep EpochNumber Source # | |||||
Defined in Cardano.Chain.Slotting.EpochNumber type Rep EpochNumber = D1 ('MetaData "EpochNumber" "Cardano.Chain.Slotting.EpochNumber" "cardano-ledger-byron-1.3.0.0-inplace" 'True) (C1 ('MetaCons "EpochNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "getEpochNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |||||
addSlotCount ∷ SlotCount → SlotNumber → SlotNumber Source #
Increase a SlotNumber by SlotCount
newtype EpochSlots Source #
The number of slots per epoch.
Constructors
| EpochSlots | |
Fields | |
Instances
| FromCBOR EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots | |||||
| ToCBOR EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods toCBOR ∷ EpochSlots → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy EpochSlots → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [EpochSlots] → Size Source # | |||||
| DecCBOR EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots | |||||
| EncCBOR EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods encCBOR ∷ EpochSlots → Encoding Source # | |||||
| Buildable EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods build ∷ EpochSlots → Builder Source # | |||||
| Data EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods gfoldl ∷ (∀ d b. Data d ⇒ c (d → b) → d → c b) → (∀ g. g → c g) → EpochSlots → c EpochSlots # gunfold ∷ (∀ b r. Data b ⇒ c (b → r) → c r) → (∀ r. r → c r) → Constr → c EpochSlots # toConstr ∷ EpochSlots → Constr # dataTypeOf ∷ EpochSlots → DataType # dataCast1 ∷ Typeable t ⇒ (∀ d. Data d ⇒ c (t d)) → Maybe (c EpochSlots) # dataCast2 ∷ Typeable t ⇒ (∀ d e. (Data d, Data e) ⇒ c (t d e)) → Maybe (c EpochSlots) # gmapT ∷ (∀ b. Data b ⇒ b → b) → EpochSlots → EpochSlots # gmapQl ∷ (r → r' → r) → r → (∀ d. Data d ⇒ d → r') → EpochSlots → r # gmapQr ∷ ∀ r r'. (r' → r → r) → r → (∀ d. Data d ⇒ d → r') → EpochSlots → r # gmapQ ∷ (∀ d. Data d ⇒ d → u) → EpochSlots → [u] # gmapQi ∷ Int → (∀ d. Data d ⇒ d → u) → EpochSlots → u # gmapM ∷ Monad m ⇒ (∀ d. Data d ⇒ d → m d) → EpochSlots → m EpochSlots # gmapMp ∷ MonadPlus m ⇒ (∀ d. Data d ⇒ d → m d) → EpochSlots → m EpochSlots # gmapMo ∷ MonadPlus m ⇒ (∀ d. Data d ⇒ d → m d) → EpochSlots → m EpochSlots # | |||||
| Generic EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Associated Types
| |||||
| Read EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods readsPrec ∷ Int → ReadS EpochSlots # readList ∷ ReadS [EpochSlots] # | |||||
| Show EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods showsPrec ∷ Int → EpochSlots → ShowS # show ∷ EpochSlots → String # showList ∷ [EpochSlots] → ShowS # | |||||
| Eq EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots | |||||
| Ord EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots Methods compare ∷ EpochSlots → EpochSlots → Ordering # (<) ∷ EpochSlots → EpochSlots → Bool # (<=) ∷ EpochSlots → EpochSlots → Bool # (>) ∷ EpochSlots → EpochSlots → Bool # (>=) ∷ EpochSlots → EpochSlots → Bool # max ∷ EpochSlots → EpochSlots → EpochSlots # min ∷ EpochSlots → EpochSlots → EpochSlots # | |||||
| NoThunks EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots | |||||
| type Rep EpochSlots Source # | |||||
Defined in Cardano.Chain.Slotting.EpochSlots type Rep EpochSlots = D1 ('MetaData "EpochSlots" "Cardano.Chain.Slotting.EpochSlots" "cardano-ledger-byron-1.3.0.0-inplace" 'True) (C1 ('MetaCons "EpochSlots" 'PrefixI 'True) (S1 ('MetaSel ('Just "unEpochSlots") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |||||
data EpochAndSlotCount Source #
EpochAndSlotCount identifies a slot by its EpochNumber and the number of
slots into the epoch that it sits
Constructors
| EpochAndSlotCount | |
Fields
| |
Instances
| FromCBOR EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount | |||||
| ToCBOR EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods toCBOR ∷ EpochAndSlotCount → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy EpochAndSlotCount → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [EpochAndSlotCount] → Size Source # | |||||
| DecCBOR EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount | |||||
| EncCBOR EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods | |||||
| NFData EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods rnf ∷ EpochAndSlotCount → () # | |||||
| Buildable EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods | |||||
| Generic EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Associated Types
Methods from ∷ EpochAndSlotCount → Rep EpochAndSlotCount x # to ∷ Rep EpochAndSlotCount x → EpochAndSlotCount # | |||||
| Show EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods showsPrec ∷ Int → EpochAndSlotCount → ShowS # show ∷ EpochAndSlotCount → String # showList ∷ [EpochAndSlotCount] → ShowS # | |||||
| Eq EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods | |||||
| Ord EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount Methods compare ∷ EpochAndSlotCount → EpochAndSlotCount → Ordering # (<) ∷ EpochAndSlotCount → EpochAndSlotCount → Bool # (<=) ∷ EpochAndSlotCount → EpochAndSlotCount → Bool # (>) ∷ EpochAndSlotCount → EpochAndSlotCount → Bool # (>=) ∷ EpochAndSlotCount → EpochAndSlotCount → Bool # max ∷ EpochAndSlotCount → EpochAndSlotCount → EpochAndSlotCount # min ∷ EpochAndSlotCount → EpochAndSlotCount → EpochAndSlotCount # | |||||
| type Rep EpochAndSlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.EpochAndSlotCount type Rep EpochAndSlotCount = D1 ('MetaData "EpochAndSlotCount" "Cardano.Chain.Slotting.EpochAndSlotCount" "cardano-ledger-byron-1.3.0.0-inplace" 'False) (C1 ('MetaCons "EpochAndSlotCount" 'PrefixI 'True) (S1 ('MetaSel ('Just "epochNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 EpochNumber) :*: S1 ('MetaSel ('Just "slotCount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotCount))) | |||||
fromSlotNumber ∷ EpochSlots → SlotNumber → EpochAndSlotCount Source #
Construct a EpochAndSlotCount from a SlotNumber, using a given EpochSlots
A number of slots
Constructors
| SlotCount | |
Fields | |
Instances
| FromCBOR SlotCount Source # | |||||
| ToCBOR SlotCount Source # | |||||
| DecCBOR SlotCount Source # | |||||
| EncCBOR SlotCount Source # | |||||
| NFData SlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.SlotCount | |||||
| Buildable SlotCount Source # | |||||
| Generic SlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.SlotCount Associated Types
| |||||
| Read SlotCount Source # | |||||
| Show SlotCount Source # | |||||
| Eq SlotCount Source # | |||||
| Ord SlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.SlotCount | |||||
| type Rep SlotCount Source # | |||||
Defined in Cardano.Chain.Slotting.SlotCount | |||||
epochFirstSlot ∷ EpochSlots → EpochNumber → SlotNumber Source #
Calculate the first slot in an epoch.
Note that this function will give an undetermined result if Byron is not the
first and only era - a more robust method should use EpochInfo from
cardano-slotting.
data WithEpochSlots a Source #
Data with an accompanying slots per epoch context.
Constructors
| WithEpochSlots | |
Fields | |
Instances
| Buildable (WithEpochSlots Block) Source # | |
Defined in Cardano.Chain.Block.Block | |
| Buildable (WithEpochSlots Header) Source # | |
Defined in Cardano.Chain.Block.Header | |
| Show a ⇒ Show (WithEpochSlots a) Source # | |
Defined in Cardano.Chain.Slotting.EpochSlots Methods showsPrec ∷ Int → WithEpochSlots a → ShowS # show ∷ WithEpochSlots a → String # showList ∷ [WithEpochSlots a] → ShowS # | |
| Eq a ⇒ Eq (WithEpochSlots a) Source # | |
Defined in Cardano.Chain.Slotting.EpochSlots Methods (==) ∷ WithEpochSlots a → WithEpochSlots a → Bool # (/=) ∷ WithEpochSlots a → WithEpochSlots a → Bool # | |
toSlotNumber ∷ EpochSlots → EpochAndSlotCount → SlotNumber Source #
Flatten EpochAndSlotCount into a single absolute SlotNumber
Arguments
| ∷ EpochNumber | Unlock stake epoch |
| → EpochNumber | Epoch in question (for which we determine whether it belongs to the bootstrap era) |
| → Bool |
Bootstrap era is ongoing until stakes are unlocked. The reward era starts from the epoch specified as the epoch that unlocks stakes:
[unlock stake epoch]
/
Epoch: ... E-3 E-2 E-1 E+0 E+1 E+2 E+3 ...
------------------ | -----------------------
Bootstrap era Reward era