Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.HardFork.Combinator.State
Description
Intended for qualified import
import Ouroboros.Consensus.HardFork.Combinator.State (HardForkState(..)) import qualified Ouroboros.Consensus.HardFork.Combinator.State as State
Synopsis
- module Ouroboros.Consensus.HardFork.Combinator.State.Infra
- module Ouroboros.Consensus.HardFork.Combinator.State.Types
- getTip ∷ ∀ f (xs ∷ [Type]). CanHardFork xs ⇒ (∀ blk. SingleEraBlock blk ⇒ f blk → Point blk) → HardForkState f xs → Point (HardForkBlock xs)
- recover ∷ ∀ (f ∷ Type → Type) (xs ∷ [Type]). CanHardFork xs ⇒ Telescope (K Past ∷ Type → Type) f xs → HardForkState f xs
- epochInfoLedger ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → EpochInfo (Except PastHorizonException)
- epochInfoPrecomputedTransitionInfo ∷ ∀ (xs ∷ [Type]) (f ∷ Type → Type). Shape xs → TransitionInfo → HardForkState f xs → EpochInfo (Except PastHorizonException)
- mostRecentTransitionInfo ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → TransitionInfo
- reconstructSummaryLedger ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → Summary xs
- extendToSlot ∷ ∀ (xs ∷ [Type]). CanHardFork xs ⇒ HardForkLedgerConfig xs → SlotNo → HardForkState (Flip LedgerState EmptyMK) xs → HardForkState (Flip LedgerState DiffMK) xs
Documentation
Support for defining instances
getTip ∷ ∀ f (xs ∷ [Type]). CanHardFork xs ⇒ (∀ blk. SingleEraBlock blk ⇒ f blk → Point blk) → HardForkState f xs → Point (HardForkBlock xs) Source #
Serialisation support
recover ∷ ∀ (f ∷ Type → Type) (xs ∷ [Type]). CanHardFork xs ⇒ Telescope (K Past ∷ Type → Type) f xs → HardForkState f xs Source #
Recover HardForkState
from partial information
The primary goal of this is to make sure that for the current state we
really only need to store the underlying f
. It is not strictly essential
that this is possible but it helps with the unary hardfork case, and it may
in general help with binary compatibility.
EpochInfo
epochInfoLedger ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → EpochInfo (Except PastHorizonException) Source #
epochInfoPrecomputedTransitionInfo ∷ ∀ (xs ∷ [Type]) (f ∷ Type → Type). Shape xs → TransitionInfo → HardForkState f xs → EpochInfo (Except PastHorizonException) Source #
Construct EpochInfo
given precomputed TransitionInfo
The transition and state arguments are acquired either from a ticked ledger state or a ledger view.
mostRecentTransitionInfo ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → TransitionInfo Source #
reconstructSummaryLedger ∷ ∀ (xs ∷ [Type]) (mk ∷ MapKind). All SingleEraBlock xs ⇒ HardForkLedgerConfig xs → HardForkState (Flip LedgerState mk) xs → Summary xs Source #
Ledger specific functionality
extendToSlot ∷ ∀ (xs ∷ [Type]). CanHardFork xs ⇒ HardForkLedgerConfig xs → SlotNo → HardForkState (Flip LedgerState EmptyMK) xs → HardForkState (Flip LedgerState DiffMK) xs Source #
Extend the telescope until the specified slot is within the era at the tip.
Note that transitioning to a later era might create new values in the ledger
tables, therefore the result of this function is a DiffMK
.
If we are crossing no era boundaries, this whole function is a no-op that
only creates an empty DiffMK
, because the Telescope.extend
function will
do nothing.
If we are crossing one era boundary, the ledger tables might be populated
with whatever translateLedgerStateWith
returns.
If we are crossing multiple era boundaries, the diffs generated when crossing an era boundary will be prepended to the ones produced by later era boundaries and, in order to all match the resulting era, they will be translated to later eras.
This means in particular that if we extend from era1
to era3
going
through era2
, we will:
- translate the ledger state from
era1
toera2
, which produces aera2
ledger state together with a some set of differences. - keep the
era2
diffs aside, and translate theera2
ledger state without ledger tables, which produces aera3
ledger state together with a set ofera3
differences. - Translate the
era2
diffs toera3
differences, and prepend them to the ones created in the step 2. - Attach the diffs resulting from step 3 to the
era3
ledger state from step 2, and return it.