| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Peras.Context
Synopsis
- data BoundedPerasEpochContext blk = BoundedPerasEpochContext {}
- withinEpochContext ∷ PerasRoundNo → BoundedPerasEpochContext blk → Maybe (PerasEpochContext blk)
- data PerasEpochContextResolver blk
- data PerasEpochContextNotFoundForRound = PerasEpochContextNotFoundForRound !PerasRoundNo !String
- resolveRoundNo ∷ PerasEpochContextResolver blk → PerasRoundNo → Either PerasEpochContextNotFoundForRound (PerasEpochContext blk)
- perasEpochContextResolverBounds ∷ PerasEpochContextResolver blk → (PerasRoundNo, PerasRoundNo)
- newtype PerasEpochContextResolverHandle (m ∷ Type → Type) blk = PerasEpochContextResolverHandle {}
- mockPerasEpochContextResolverHandle ∷ (IOLike m, NoThunks (PerasEpochContext blk)) ⇒ PerasEpochContext blk → m (PerasEpochContextResolverHandle m blk)
- withResolvedRoundNo ∷ ∀ (m ∷ Type → Type) err blk a. (MonadSTM m, MonadThrow (STM m), Exception err) ⇒ PerasEpochContextResolverHandle m blk → PerasRoundNo → (PerasEpochContext blk → Either err a) → STM m a
- class (HasHardForkHistory blk, LedgerStateSupportsPeras (LedgerState blk), LedgerStateSupportsPeras (Ticked LedgerState blk), ChainDepStateSupportsPeras (ChainDepState (BlockProtocol blk)), ChainDepStateSupportsPeras (Ticked (ChainDepState (BlockProtocol blk))), IsPerasError (PerasError blk) blk, Show (PerasError blk), Show (PerasVotingCommittee blk), Eq (PerasVotingCommittee blk), NoThunks (PerasVotingCommittee blk), Typeable (PerasVotingCommittee blk), FromCBOR (PerasVotingCommittee blk), ToCBOR (PerasVotingCommittee blk), Show (PerasEpochContextResolver blk), Eq (PerasEpochContextResolver blk), NoThunks (PerasEpochContextResolver blk), Typeable (PerasEpochContextResolver blk), FromCBOR (PerasEpochContextResolver blk), ToCBOR (PerasEpochContextResolver blk), EncodeDisk blk (PerasEpochContextResolver blk), DecodeDisk blk (PerasEpochContextResolver blk)) ⇒ StateSupportsPerasEpochContext blk where
- type MaybeEraIndexedEpochToPerasRoundInfo blk
- fromMaybeEraIndexedEpochToPerasRoundInfo ∷ proxy blk → MaybeEraIndexedEpochToPerasRoundInfo blk → EpochToPerasRoundInfo
- toMaybeEraIndexedEpochToPerasRoundInfo ∷ All (Top ∷ Type → Constraint) (HardForkIndices blk) ⇒ proxy blk → EraIndexed (HardForkIndices blk) EpochToPerasRoundInfo → MaybeEraIndexedEpochToPerasRoundInfo blk
- mkBoundedPerasEpochContext ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ MaybeEraIndexedEpochToPerasRoundInfo blk → ledgerState EmptyMK → chainDepState → Either (PerasError blk) (BoundedPerasEpochContext blk)
- mkBoundedPerasEpochContextWith ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState, CryptoSupportsVotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk), MaybeEraIndexedEpochToPerasRoundInfo blk ~ EpochToPerasRoundInfo, IsPerasError (PerasError blk) blk) ⇒ ((LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ ledgerState EmptyMK → chainDepState → Either (PerasError blk) (PerasVotingCommitteeInput blk)) → MaybeEraIndexedEpochToPerasRoundInfo blk → ledgerState EmptyMK → chainDepState → Either (PerasError blk) (BoundedPerasEpochContext blk)
- initPerasEpochContextResolver ∷ (All (Top ∷ Type → Constraint) (HardForkIndices blk), StateSupportsPerasEpochContext blk) ⇒ LedgerConfig blk → LedgerState blk EmptyMK → HeaderState blk → PerasEpochContextResolver blk
- tickPerasEpochContextResolver ∷ (All (Top ∷ Type → Constraint) (HardForkIndices blk), StateSupportsPerasEpochContext blk) ⇒ LedgerConfig blk → (PerasEpochContextResolver blk, LedgerState blk EmptyMK, HeaderState blk) → (SlotNo, Ticked LedgerState blk EmptyMK, Ticked (HeaderState blk)) → PerasEpochContextResolver blk
- data TimeResolutionContext blk where
- TimeResolutionContext ∷ ∀ blk (mk ∷ MapKind). LedgerConfig blk → LedgerState blk mk → TimeResolutionContext blk
- runQueryWithContext ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → Qry a → Either PastHorizonException a
- runQueryEraIndexedWithContext ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → Qry a → Either PastHorizonException (EraIndexed (HardForkIndices blk) a)
- newtype TimeResolutionContextHandle (m ∷ Type → Type) blk = TimeResolutionContextHandle {
- getTimeResolutionContext ∷ STM m (TimeResolutionContext blk)
- runQueryWithContextHandle ∷ ∀ blk (m ∷ Type → Type) a. (HasHardForkHistory blk, MonadSTM m) ⇒ TimeResolutionContextHandle m blk → Qry a → STM m (Either PastHorizonException a)
- data EpochCrossing a
- = SameEpoch
- | NextEpoch !a
- | ManyEpochsCrossed !a
- data DetectNextEpochError
- isNextEpoch ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → WithOrigin SlotNo → SlotNo → Either DetectNextEpochError (EpochCrossing (EraIndexed (HardForkIndices blk) (PerasEnabled EpochToPerasRoundInfo)))
Bounded Peras epoch context
data BoundedPerasEpochContext blk Source #
A PerasEpochContext that is valid only in a given range of round numbers
Constructors
| BoundedPerasEpochContext | |
Fields
| |
Instances
withinEpochContext ∷ PerasRoundNo → BoundedPerasEpochContext blk → Maybe (PerasEpochContext blk) Source #
Check whether a given PerasRoundNo is within the bounds of a
BoundedPerasEpochContext.
Returns the corresponding PerasEpochContext if the round number is within
the bounds, or Nothing otherwise.
Peras epoch context resolver and handle
data PerasEpochContextResolver blk Source #
A two-epoch window of Peras epoch contexts, which can be used to resolve round numbers into their corresponding Peras contexts.
Constructors
| PerasEpochContextResolverError !String | The resolver is in an error state, and cannot resolve any round number. NOTE: this exists to allow for recoverable errors during resolver initialisation or ticking caused, e.g., by incorrect parameterization. |
| PerasEpochContextResolver | The resolver has a two-epoch window of Peras epoch contexts, which may be empty if Peras is not enabled in either of these epochs. |
Fields
| |
Instances
| FromCBOR (PerasEpochContextResolver blk) ⇒ DecodeDisk blk (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Methods decodeDisk ∷ CodecConfig blk → ∀ s. Decoder s (PerasEpochContextResolver blk) Source # | |||||
| ToCBOR (PerasEpochContextResolver blk) ⇒ EncodeDisk blk (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Methods encodeDisk ∷ CodecConfig blk → PerasEpochContextResolver blk → Encoding Source # | |||||
| (Typeable blk, FromCBOR (PerasVotingCommittee blk)) ⇒ FromCBOR (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context | |||||
| (Typeable blk, ToCBOR (PerasVotingCommittee blk)) ⇒ ToCBOR (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Methods toCBOR ∷ PerasEpochContextResolver blk → Encoding Source # encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (PerasEpochContextResolver blk) → Size Source # encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [PerasEpochContextResolver blk] → Size Source # | |||||
| Eq (PerasEpochContext blk) ⇒ Eq (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Methods (==) ∷ PerasEpochContextResolver blk → PerasEpochContextResolver blk → Bool # (/=) ∷ PerasEpochContextResolver blk → PerasEpochContextResolver blk → Bool # | |||||
| Generic (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Associated Types
Methods from ∷ PerasEpochContextResolver blk → Rep (PerasEpochContextResolver blk) x # to ∷ Rep (PerasEpochContextResolver blk) x → PerasEpochContextResolver blk # | |||||
| Show (PerasEpochContext blk) ⇒ Show (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Methods showsPrec ∷ Int → PerasEpochContextResolver blk → ShowS # show ∷ PerasEpochContextResolver blk → String # showList ∷ [PerasEpochContextResolver blk] → ShowS # | |||||
| NoThunks (PerasEpochContext blk) ⇒ NoThunks (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context | |||||
| type Rep (PerasEpochContextResolver blk) Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context type Rep (PerasEpochContextResolver blk) = D1 ('MetaData "PerasEpochContextResolver" "Ouroboros.Consensus.Peras.Context" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasEpochContextResolverError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)) :+: C1 ('MetaCons "PerasEpochContextResolver" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasEnabled (BoundedPerasEpochContext blk))) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PerasEnabled (BoundedPerasEpochContext blk))))) | |||||
data PerasEpochContextNotFoundForRound Source #
An error indicating that a PerasEpochContext could not be found for a
given PerasRoundNo in a PerasEpochContextResolver.
Constructors
| PerasEpochContextNotFoundForRound | |
Fields
| |
Instances
| Eq PerasEpochContextNotFoundForRound Source # | |||||
| Exception PerasEpochContextNotFoundForRound Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context | |||||
| Generic PerasEpochContextNotFoundForRound Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context Associated Types
| |||||
| Show PerasEpochContextNotFoundForRound Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context | |||||
| NoThunks PerasEpochContextNotFoundForRound Source # | |||||
| type Rep PerasEpochContextNotFoundForRound Source # | |||||
Defined in Ouroboros.Consensus.Peras.Context type Rep PerasEpochContextNotFoundForRound = D1 ('MetaData "PerasEpochContextNotFoundForRound" "Ouroboros.Consensus.Peras.Context" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "PerasEpochContextNotFoundForRound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PerasRoundNo) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String))) | |||||
resolveRoundNo ∷ PerasEpochContextResolver blk → PerasRoundNo → Either PerasEpochContextNotFoundForRound (PerasEpochContext blk) Source #
Resolve a PerasRoundNo into its corresponding PerasEpochContext using a
PerasEpochContextResolver.
Fails with PerasEpochContextNotFoundForRound if the round number is not
within the bounds of either the current or previous epoch context, or if the
resolver is in an error state.
perasEpochContextResolverBounds ∷ PerasEpochContextResolver blk → (PerasRoundNo, PerasRoundNo) Source #
Compute the bounds of the Peras round numbers that are covered by the
given PerasEpochContextResolver.
NOTE: the upper bound is exclusive, thus we return an empty range [0,0) when the resolver doesn't cover any Peras round.
newtype PerasEpochContextResolverHandle (m ∷ Type → Type) blk Source #
A handle to a PerasEpochContextResolver that can be used in STM to
resolve round numbers into their corresponding PerasEpochContexts.
Constructors
| PerasEpochContextResolverHandle | |
Fields | |
mockPerasEpochContextResolverHandle ∷ (IOLike m, NoThunks (PerasEpochContext blk)) ⇒ PerasEpochContext blk → m (PerasEpochContextResolverHandle m blk) Source #
A mocked PerasEpochContextResolverHandle that always succeeds by
resolving every round number to a fixed given (fixed) PerasEpochContext.
withResolvedRoundNo ∷ ∀ (m ∷ Type → Type) err blk a. (MonadSTM m, MonadThrow (STM m), Exception err) ⇒ PerasEpochContextResolverHandle m blk → PerasRoundNo → (PerasEpochContext blk → Either err a) → STM m a Source #
Helper to resolve the epoch context for a given round a pass it to a continuation for further processing.
NOTE: this function will throw an STM exception if round number cannot be resolved, or if the continuation fails.
Extracting and resolving Peras epoch contexts from the node state
class (HasHardForkHistory blk, LedgerStateSupportsPeras (LedgerState blk), LedgerStateSupportsPeras (Ticked LedgerState blk), ChainDepStateSupportsPeras (ChainDepState (BlockProtocol blk)), ChainDepStateSupportsPeras (Ticked (ChainDepState (BlockProtocol blk))), IsPerasError (PerasError blk) blk, Show (PerasError blk), Show (PerasVotingCommittee blk), Eq (PerasVotingCommittee blk), NoThunks (PerasVotingCommittee blk), Typeable (PerasVotingCommittee blk), FromCBOR (PerasVotingCommittee blk), ToCBOR (PerasVotingCommittee blk), Show (PerasEpochContextResolver blk), Eq (PerasEpochContextResolver blk), NoThunks (PerasEpochContextResolver blk), Typeable (PerasEpochContextResolver blk), FromCBOR (PerasEpochContextResolver blk), ToCBOR (PerasEpochContextResolver blk), EncodeDisk blk (PerasEpochContextResolver blk), DecodeDisk blk (PerasEpochContextResolver blk)) ⇒ StateSupportsPerasEpochContext blk where Source #
Type-class for blocks that support constructing a Peras epoch contexts from their corresponding ledger and chain-dep states.
Associated Types
type MaybeEraIndexedEpochToPerasRoundInfo blk Source #
Epoch-dependent information needed to resolve a PerasRoundNo into its
corresponding PerasEpochContext. In practice, this is always an
EpochToPerasRoundInfo, with the exception of the HardForkBlock, which
additionally takes advantage of the era index returned by
runQueryEraIndexed to be able to dispatch to the correct era-specific
implementation.
Methods
fromMaybeEraIndexedEpochToPerasRoundInfo ∷ proxy blk → MaybeEraIndexedEpochToPerasRoundInfo blk → EpochToPerasRoundInfo Source #
Extract a EpochToPerasRoundInfo the opaque
MaybeEraIndexedEpochToPerasRoundInfo of this block.
toMaybeEraIndexedEpochToPerasRoundInfo ∷ All (Top ∷ Type → Constraint) (HardForkIndices blk) ⇒ proxy blk → EraIndexed (HardForkIndices blk) EpochToPerasRoundInfo → MaybeEraIndexedEpochToPerasRoundInfo blk Source #
Inject an era-indexed EpochToPerasRoundInfo into an opaque
MaybeEraIndexedEpochToPerasRoundInfo of this block.
mkBoundedPerasEpochContext ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ MaybeEraIndexedEpochToPerasRoundInfo blk → ledgerState EmptyMK → chainDepState → Either (PerasError blk) (BoundedPerasEpochContext blk) Source #
Create a bounded epoch context from a given epoch-to-round info.
Instances
| CanHardFork xs ⇒ StateSupportsPerasEpochContext (HardForkBlock xs) Source # | |||||
Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger Associated Types
Methods fromMaybeEraIndexedEpochToPerasRoundInfo ∷ proxy (HardForkBlock xs) → MaybeEraIndexedEpochToPerasRoundInfo (HardForkBlock xs) → EpochToPerasRoundInfo Source # toMaybeEraIndexedEpochToPerasRoundInfo ∷ All (Top ∷ Type → Constraint) (HardForkIndices (HardForkBlock xs)) ⇒ proxy (HardForkBlock xs) → EraIndexed (HardForkIndices (HardForkBlock xs)) EpochToPerasRoundInfo → MaybeEraIndexedEpochToPerasRoundInfo (HardForkBlock xs) Source # mkBoundedPerasEpochContext ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ MaybeEraIndexedEpochToPerasRoundInfo (HardForkBlock xs) → ledgerState EmptyMK → chainDepState → Either (PerasError (HardForkBlock xs)) (BoundedPerasEpochContext (HardForkBlock xs)) Source # | |||||
| (Bridge m a, Typeable m, Typeable a, ChainDepStateSupportsPeras (ChainDepState (BlockProtocol m)), ChainDepStateSupportsPeras (Ticked (ChainDepState (BlockProtocol m)))) ⇒ StateSupportsPerasEpochContext (DualBlock m a) Source # | |||||
Defined in Ouroboros.Consensus.Ledger.Dual Associated Types
Methods fromMaybeEraIndexedEpochToPerasRoundInfo ∷ proxy (DualBlock m a) → MaybeEraIndexedEpochToPerasRoundInfo (DualBlock m a) → EpochToPerasRoundInfo Source # toMaybeEraIndexedEpochToPerasRoundInfo ∷ All (Top ∷ Type → Constraint) (HardForkIndices (DualBlock m a)) ⇒ proxy (DualBlock m a) → EraIndexed (HardForkIndices (DualBlock m a)) EpochToPerasRoundInfo → MaybeEraIndexedEpochToPerasRoundInfo (DualBlock m a) Source # mkBoundedPerasEpochContext ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ MaybeEraIndexedEpochToPerasRoundInfo (DualBlock m a) → ledgerState EmptyMK → chainDepState → Either (PerasError (DualBlock m a)) (BoundedPerasEpochContext (DualBlock m a)) Source # | |||||
mkBoundedPerasEpochContextWith ∷ (LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState, CryptoSupportsVotingCommittee (PerasCrypto blk) (PerasVotingCommitteeScheme blk), MaybeEraIndexedEpochToPerasRoundInfo blk ~ EpochToPerasRoundInfo, IsPerasError (PerasError blk) blk) ⇒ ((LedgerStateSupportsPeras ledgerState, ChainDepStateSupportsPeras chainDepState) ⇒ ledgerState EmptyMK → chainDepState → Either (PerasError blk) (PerasVotingCommitteeInput blk)) → MaybeEraIndexedEpochToPerasRoundInfo blk → ledgerState EmptyMK → chainDepState → Either (PerasError blk) (BoundedPerasEpochContext blk) Source #
Helper to build a BoundedPerasEpochContext using a function that produces
a PerasVotingCommitteeInput from a ledger and chain-dep state.
NOTE: this is useful to define instances for StateSupportsPerasEpochContext
where mkBoundedPerasEpochContext is instantiated to either:
* mkBoundedPerasEpochContextWith mkMockPerasVotingCommitteeInput for test
types with limited Peras support, and
* mkBoundedPerasEpochContextWith V1.mkPerasVotingCommitteeInput for
production types.
initPerasEpochContextResolver ∷ (All (Top ∷ Type → Constraint) (HardForkIndices blk), StateSupportsPerasEpochContext blk) ⇒ LedgerConfig blk → LedgerState blk EmptyMK → HeaderState blk → PerasEpochContextResolver blk Source #
Initialize a PerasEpochContextResolver from a ledger and header state.
NOTES:
1. We may later decide that a PerasEpochContextResolver is always
initiated with empty/error value, and rely on the first ticking to
properly initialize it. In the current architecture, however, that would
work only if the first ticking happens when the previous slot is either
Origin, or a slot from a previous epoch compared to the target slot.
2. Given that we have no assumption that (1) would work, we made a
polymorphic system where a BoundedEpochContext can be created from
either a ticked or unticked ledger+header state
(see LedgerStateSupportsPeras and ChainDepStateSupportsPeras
helper classes). This way, a PerasEpochContextResolver can be
initialized from unticked LedgerState and HeaderState, but then
ticked by using the 'Ticked LedgerState' and 'Ticked HeaderState'.
3. If in the future we move on to a system where the resolver is always
initialized with empty/error value, we can remove the polymorphic system
and only create a BoundedPerasEpochContext from 'Ticked LedgerState'
and 'Ticked HeaderState'.
tickPerasEpochContextResolver Source #
Arguments
| ∷ (All (Top ∷ Type → Constraint) (HardForkIndices blk), StateSupportsPerasEpochContext blk) | |
| ⇒ LedgerConfig blk | |
| → (PerasEpochContextResolver blk, LedgerState blk EmptyMK, HeaderState blk) | The fields needed from the previous |
| → (SlotNo, Ticked LedgerState blk EmptyMK, Ticked (HeaderState blk)) | Target |
| → PerasEpochContextResolver blk |
Tick a PerasEpochContextResolver to a target SlotNo.
NOTES:
1. To avoid circular dependencies, this function uses a deconstructed
ExtLedgerState instead of the ExtLedgerState itself.
2. It doesn't seem to bring much to differentiate a
PerasEpochContextResolver from a ticked one at type level, since they
need to carry exactly the same information. We tried, and it didn't
improve readability.
Time resolution
data TimeResolutionContext blk where Source #
Data needed to run time-dependent queries.
NOTE: this is existential on the MapKind of the ledger state, as we really
don't care about it for the purpose of time resolution.
Constructors
| TimeResolutionContext ∷ ∀ blk (mk ∷ MapKind). LedgerConfig blk → LedgerState blk mk → TimeResolutionContext blk |
runQueryWithContext ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → Qry a → Either PastHorizonException a Source #
Wrapper over runQuery that uses a TimeResolutionContext to build a
Summary.
runQueryEraIndexedWithContext ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → Qry a → Either PastHorizonException (EraIndexed (HardForkIndices blk) a) Source #
Wrapper over runQueryEraIndexed that uses a TimeResolutionContext to
build a Summary.
newtype TimeResolutionContextHandle (m ∷ Type → Type) blk Source #
A handle to an STM action that returns a TimeResolutionContext.
Constructors
| TimeResolutionContextHandle | |
Fields
| |
runQueryWithContextHandle ∷ ∀ blk (m ∷ Type → Type) a. (HasHardForkHistory blk, MonadSTM m) ⇒ TimeResolutionContextHandle m blk → Qry a → STM m (Either PastHorizonException a) Source #
Helper to run a time-dependent query using a TimeResolutionContextHandle.
Next-epoch detection
data EpochCrossing a Source #
The outcome of comparing the epoch of a previous slot with the epoch of a target slot when ticking the ledger, discriminated by how many epoch boundaries were crossed. This drives how the Peras epoch-context resolver is updated.
Constructors
| SameEpoch | The target slot is in the same epoch as the previous slot: no epoch boundary was crossed. |
| NextEpoch !a | Exactly one epoch boundary was crossed. The resolver can be advanced incrementally (the current context becomes the previous one). |
| ManyEpochsCrossed !a | More than one epoch boundary was crossed at once, i.e. the chain skipped one or more entire epochs. This is only possible for a sparse/empty chain, or when ticking the ledger far ahead of its tip. The two-epoch window cannot be advanced incrementally across the gap, so the resolver must be re-initialised at the target epoch instead. |
Instances
| Functor EpochCrossing Source # | |
Defined in Ouroboros.Consensus.Peras.Context Methods fmap ∷ (a → b) → EpochCrossing a → EpochCrossing b # (<$) ∷ a → EpochCrossing b → EpochCrossing a # | |
| Foldable EpochCrossing Source # | |
Defined in Ouroboros.Consensus.Peras.Context Methods fold ∷ Monoid m ⇒ EpochCrossing m → m # foldMap ∷ Monoid m ⇒ (a → m) → EpochCrossing a → m # foldMap' ∷ Monoid m ⇒ (a → m) → EpochCrossing a → m # foldr ∷ (a → b → b) → b → EpochCrossing a → b # foldr' ∷ (a → b → b) → b → EpochCrossing a → b # foldl ∷ (b → a → b) → b → EpochCrossing a → b # foldl' ∷ (b → a → b) → b → EpochCrossing a → b # foldr1 ∷ (a → a → a) → EpochCrossing a → a # foldl1 ∷ (a → a → a) → EpochCrossing a → a # toList ∷ EpochCrossing a → [a] # null ∷ EpochCrossing a → Bool # length ∷ EpochCrossing a → Int # elem ∷ Eq a ⇒ a → EpochCrossing a → Bool # maximum ∷ Ord a ⇒ EpochCrossing a → a # minimum ∷ Ord a ⇒ EpochCrossing a → a # sum ∷ Num a ⇒ EpochCrossing a → a # product ∷ Num a ⇒ EpochCrossing a → a # | |
| Traversable EpochCrossing Source # | |
Defined in Ouroboros.Consensus.Peras.Context Methods traverse ∷ Applicative f ⇒ (a → f b) → EpochCrossing a → f (EpochCrossing b) # sequenceA ∷ Applicative f ⇒ EpochCrossing (f a) → f (EpochCrossing a) # mapM ∷ Monad m ⇒ (a → m b) → EpochCrossing a → m (EpochCrossing b) # sequence ∷ Monad m ⇒ EpochCrossing (m a) → m (EpochCrossing a) # | |
| Show a ⇒ Show (EpochCrossing a) Source # | |
Defined in Ouroboros.Consensus.Peras.Context Methods showsPrec ∷ Int → EpochCrossing a → ShowS # show ∷ EpochCrossing a → String # showList ∷ [EpochCrossing a] → ShowS # | |
data DetectNextEpochError Source #
Errors that can occur when detecting whether a target slot is in the next epoch compared to a previous slot.
Instances
| Exception DetectNextEpochError Source # | |
| Show DetectNextEpochError Source # | |
Defined in Ouroboros.Consensus.Peras.Context Methods showsPrec ∷ Int → DetectNextEpochError → ShowS # show ∷ DetectNextEpochError → String # showList ∷ [DetectNextEpochError] → ShowS # | |
isNextEpoch ∷ HasHardForkHistory blk ⇒ TimeResolutionContext blk → WithOrigin SlotNo → SlotNo → Either DetectNextEpochError (EpochCrossing (EraIndexed (HardForkIndices blk) (PerasEnabled EpochToPerasRoundInfo))) Source #
Determine whether a target slot is in the next epoch compared to a previous slot, and if so, how many epoch boundaries were crossed.