Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Chain.Slotting
Synopsis
- newtype SlotNumber = SlotNumber {}
- addSlotCount :: SlotCount -> SlotNumber -> SlotNumber
- subSlotCount :: SlotCount -> SlotNumber -> SlotNumber
- newtype SlotCount = SlotCount {}
- newtype EpochSlots = EpochSlots {}
- data WithEpochSlots a = WithEpochSlots {
- epochSlots :: EpochSlots
- unWithEpochSlots :: a
- epochFirstSlot :: EpochSlots -> EpochNumber -> SlotNumber
- newtype EpochNumber = EpochNumber {}
- isBootstrapEra :: EpochNumber -> EpochNumber -> Bool
- data EpochAndSlotCount = EpochAndSlotCount {
- epochNo :: !EpochNumber
- slotCount :: !SlotCount
- toSlotNumber :: EpochSlots -> EpochAndSlotCount -> SlotNumber
- fromSlotNumber :: EpochSlots -> SlotNumber -> EpochAndSlotCount
- slotNumberEpoch :: EpochSlots -> SlotNumber -> EpochNumber
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
addSlotCount :: SlotCount -> SlotNumber -> SlotNumber Source #
Increase a SlotNumber
by SlotCount
subSlotCount :: SlotCount -> SlotNumber -> SlotNumber Source #
Decrease a SlotNumber
by SlotCount
, going no lower than 0
A number of slots
Constructors
SlotCount | |
Fields |
Instances
Eq SlotCount Source # | |
Ord SlotCount Source # | |
Defined in Cardano.Chain.Slotting.SlotCount | |
Read SlotCount Source # | |
Show SlotCount Source # | |
Generic SlotCount Source # | |
NFData SlotCount Source # | |
Defined in Cardano.Chain.Slotting.SlotCount | |
ToCBOR SlotCount Source # | |
FromCBOR SlotCount Source # | |
Buildable SlotCount Source # | |
type Rep SlotCount Source # | |
Defined in Cardano.Chain.Slotting.SlotCount |
newtype EpochSlots Source #
The number of slots per epoch.
Constructors
EpochSlots | |
Fields |
Instances
data WithEpochSlots a Source #
Data with an accompanying slots per epoch context.
Constructors
WithEpochSlots | |
Fields
|
Instances
Eq a => Eq (WithEpochSlots a) Source # | |
Defined in Cardano.Chain.Slotting.EpochSlots Methods (==) :: WithEpochSlots a -> WithEpochSlots a -> Bool # (/=) :: WithEpochSlots a -> WithEpochSlots a -> Bool # | |
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 # | |
Buildable (WithEpochSlots Header) Source # | |
Defined in Cardano.Chain.Block.Header | |
Buildable (WithEpochSlots Block) Source # | |
Defined in Cardano.Chain.Block.Block |
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.
newtype EpochNumber Source #
Index of epoch.
Constructors
EpochNumber | |
Fields |
Instances
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
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
toSlotNumber :: EpochSlots -> EpochAndSlotCount -> SlotNumber Source #
Flatten EpochAndSlotCount
into a single absolute SlotNumber
fromSlotNumber :: EpochSlots -> SlotNumber -> EpochAndSlotCount Source #
Construct a EpochAndSlotCount
from a SlotNumber
, using a given EpochSlots
slotNumberEpoch :: EpochSlots -> SlotNumber -> EpochNumber Source #