ouroboros-consensus-0.18.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.HardFork.History.Qry

Synopsis

Qry

data Expr (f ∷ TypeType) ∷ TypeType where Source #

Query expressions in PHOAS

Constructors

EVar ∷ f a → Expr f a 
ELitShow a ⇒ a → Expr f a 
ELetExpr f a → (f a → Expr f b) → Expr f b 
EPairExpr f a → Expr f b → Expr f (a, b) 
EFstExpr f (a, b) → Expr f a 
ESndExpr f (a, b) → Expr f b 
EAbsToRelTimeExpr f RelativeTimeExpr f TimeInEra 
EAbsToRelSlotExpr f SlotNoExpr f SlotInEra 
EAbsToRelEpochExpr f EpochNoExpr f EpochInEra 
ERelToAbsTimeExpr f TimeInEra → Expr f RelativeTime 
ERelToAbsSlotExpr f (SlotInEra, TimeInSlot) → Expr f SlotNo 
ERelToAbsEpochExpr f (EpochInEra, SlotInEpoch) → Expr f EpochNo 
ERelTimeToSlotExpr f TimeInEra → Expr f (SlotInEra, TimeInSlot) 
ERelSlotToTimeExpr f SlotInEra → Expr f TimeInEra 
ERelSlotToEpochExpr f SlotInEra → Expr f (EpochInEra, SlotInEpoch) 
ERelEpochToSlotExpr f EpochInEra → Expr f SlotInEra 
ESlotLengthExpr f SlotNoExpr f SlotLength 
EEpochSizeExpr f EpochNoExpr f EpochSize 
EGenesisWindowExpr f SlotNoExpr f GenesisWindow 

data PastHorizonException Source #

We tried to convert something that is past the horizon

That is, we tried to convert something that is past the point in time beyond which we lack information due to uncertainty about the next hard fork.

Constructors

PastHorizon 

Fields

qryFromExpr ∷ (∀ f. Expr f a) → Qry a Source #

Construct a Qry from a closed Expr

runQuery ∷ ∀ a xs. HasCallStackQry a → Summary xs → Either PastHorizonException a Source #

Run a query

Unlike an Expr, which is evaluated in a single era, a Qry is evaluated against all eras. Only if all Exprs embedded in the Qry can be evaluated in the same era (we don't want to mix properties of different eras in one query) do we return the result. If there is no era in which we can evaluate all Exprs in the Qry, we report a PastHorizonException.

NOTE: this means that queries about separate eras have to be run separately, they should not be composed into a single query. How could we know to which era which relative slot/time refers?

runQueryPureHasCallStackQry a → Summary xs → a Source #

runQueryThrow ∷ (HasCallStack, MonadThrow m) ⇒ Qry a → Summary xs → m a Source #

opaque

data QryTypeType Source #

Query

Qry adds a monadic interface on top of Expr. Although means that Qry itself is not showable, the PastHorizonException can nonetheless show the offending expression alongside the Summary against which it was evaluated.

Instances

Instances details
Applicative Qry Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Methods

pure ∷ a → Qry a #

(<*>)Qry (a → b) → Qry a → Qry b #

liftA2 ∷ (a → b → c) → Qry a → Qry b → Qry c #

(*>)Qry a → Qry b → Qry b #

(<*)Qry a → Qry b → Qry a #

Functor Qry Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Methods

fmap ∷ (a → b) → Qry a → Qry b #

(<$) ∷ a → Qry b → Qry a #

Monad Qry Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Methods

(>>=)Qry a → (a → Qry b) → Qry b #

(>>)Qry a → Qry b → Qry b #

return ∷ a → Qry a #

Interpreter

unsafeExtendSafeZoneInterpreter xs → Interpreter xs Source #

UNSAFE: extend the safe zone of the current era of the given Interpreter to be unbounded, ignoring any future hard forks.

This only has effect when the Interpreter was obtained in an era that was not the final one (in the final era, this is a no-op). The Interpreter will be made to believe that the current era is the final era, making its horizon unbounded, and thus never returning a PastHorizonException.

Use of this function is strongly discouraged, as it will ignore any future hard forks, and the results produced by the Interpreter can thus be incorrect.

opaque

data Interpreter xs Source #

Can be sent across the LocalStateQuery protocol to interpret queries in the wallet.

The Summary should be considered internal.

Instances

Instances details
Show (Interpreter xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Methods

showsPrecIntInterpreter xs → ShowS #

showInterpreter xs → String #

showList ∷ [Interpreter xs] → ShowS #

Eq (Interpreter xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Methods

(==)Interpreter xs → Interpreter xs → Bool #

(/=)Interpreter xs → Interpreter xs → Bool #

(SListI xs, Given EraParamsFormat) ⇒ Serialise (Interpreter xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Specific queries

epochToSlotEpochNoQry (SlotNo, EpochSize) Source #

Translate EpochNo to the SlotNo of the first slot in that epoch

Additionally returns the size of the epoch.

slotToEpochSlotNoQry (EpochNo, Word64, Word64) Source #

Translate SlotNo to its corresponding EpochNo

Additionally returns the relative slot within this epoch and how many slots are left in this slot.

slotToEpoch'SlotNoQry (EpochNo, Word64) Source #

Convert SlotNo to EpochNo and the relative slot within the epoch

slotToSlotLengthSlotNoQry SlotLength Source #

Acquire a slot's length

slotToWallclockSlotNoQry (RelativeTime, SlotLength) Source #

Translate SlotNo to the UTCTime at the start of that slot

Additionally returns the length of the slot.

wallclockToSlotRelativeTimeQry (SlotNo, NominalDiffTime, NominalDiffTime) Source #

Translate UTCTime to SlotNo

Additionally returns the time spent and time left in this slot.