| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Ledger.Tables.Utils
Description
A collection of useful combinators to shorten the code in other places.
This whole module provides ways to combine tables of two ledger states to produce another one. It is written very much ad-hoc and we should probably think of some way to make this more ergonomic. In particular for functions that take two ledger states, it is unclear if it will keep the in-memory part of the first or the second one.
Synopsis
- ltprj ∷ ∀ l blk (mk ∷ MapKind). (HasLedgerTables l blk, CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ l blk mk → LedgerTables blk mk
- ltwith ∷ ∀ l blk (mk' ∷ MapKind) (mk ∷ MapKind). (HasLedgerTables l blk, CanMapMK mk', CanMapKeysMK mk', ZeroableMK mk') ⇒ l blk mk → LedgerTables blk mk' → l blk mk'
- emptyLedgerTables ∷ ∀ (mk ∷ MapKind) blk. (ZeroableMK mk, LedgerTableConstraints blk) ⇒ LedgerTables blk mk
- forgetLedgerTables ∷ ∀ l blk (mk ∷ MapKind). HasLedgerTables l blk ⇒ l blk mk → l blk EmptyMK
- applyDiffForKeys ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → LedgerTables blk KeysMK → l' blk DiffMK → l' blk ValuesMK
- applyDiffForKeysOnTables ∷ HasLedgerTables l blk ⇒ LedgerTables blk ValuesMK → LedgerTables blk KeysMK → l blk DiffMK → l blk ValuesMK
- applyDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → l' blk ValuesMK
- calculateDifference ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk ValuesMK → l' blk TrackingMK
- noNewTickingDiffs ∷ ∀ l blk (any ∷ MapKind). HasLedgerTables l blk ⇒ l blk any → l blk DiffMK
- valuesAsDiffs ∷ HasLedgerTables l blk ⇒ l blk ValuesMK → l blk DiffMK
- prependDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk DiffMK → l' blk DiffMK → l' blk DiffMK
- rawPrependDiffs ∷ Ord k ⇒ DiffMK k v → DiffMK k v → DiffMK k v
- attachAndApplyDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → l' blk TrackingMK
- attachEmptyDiffs ∷ HasLedgerTables l blk ⇒ l blk ValuesMK → l blk TrackingMK
- prependTrackingDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk TrackingMK → l' blk TrackingMK → l' blk TrackingMK
- trackingToDiffs ∷ HasLedgerTables l blk ⇒ l blk TrackingMK → l blk DiffMK
- rawTrackingDiffs ∷ TrackingMK k v → DiffMK k v
- trackingToValues ∷ HasLedgerTables l blk ⇒ l blk TrackingMK → l blk ValuesMK
- unionValues ∷ Ord k ⇒ ValuesMK k v → ValuesMK k v → ValuesMK k v
- applyDiffsMK ∷ Ord k ⇒ ValuesMK k v → DiffMK k v → ValuesMK k v
- restrictValuesMK ∷ Ord k ⇒ ValuesMK k v → KeysMK k v → ValuesMK k v
- applyDiffs' ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → LedgerTables blk ValuesMK
- rawAttachAndApplyDiffs ∷ Ord k ⇒ ValuesMK k v → DiffMK k v → TrackingMK k v
- rawCalculateDifference ∷ (Ord k, Eq v) ⇒ ValuesMK k v → ValuesMK k v → TrackingMK k v
Projection and injection
ltprj ∷ ∀ l blk (mk ∷ MapKind). (HasLedgerTables l blk, CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ l blk mk → LedgerTables blk mk Source #
ltwith ∷ ∀ l blk (mk' ∷ MapKind) (mk ∷ MapKind). (HasLedgerTables l blk, CanMapMK mk', CanMapKeysMK mk', ZeroableMK mk') ⇒ l blk mk → LedgerTables blk mk' → l blk mk' Source #
Basic operations
emptyLedgerTables ∷ ∀ (mk ∷ MapKind) blk. (ZeroableMK mk, LedgerTableConstraints blk) ⇒ LedgerTables blk mk Source #
Empty values for every table
forgetLedgerTables ∷ ∀ l blk (mk ∷ MapKind). HasLedgerTables l blk ⇒ l blk mk → l blk EmptyMK Source #
Remove the ledger tables
Operations on DiffMK
Apply diffs
applyDiffForKeys ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → LedgerTables blk KeysMK → l' blk DiffMK → l' blk ValuesMK Source #
Apply diffs in l3 for keys in l2 and l1 on values from l1. Returns l3.
applyDiffForKeysOnTables ∷ HasLedgerTables l blk ⇒ LedgerTables blk ValuesMK → LedgerTables blk KeysMK → l blk DiffMK → l blk ValuesMK Source #
Apply diffs in l3 for keys in l2 and l1 on values from l1. Returns l3.
applyDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → l' blk ValuesMK Source #
Apply diffs from l2 on values from l1. Returns l2.
Create diffs
calculateDifference ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk ValuesMK → l' blk TrackingMK Source #
Calculate the differences between two ledger states. The first ledger state is considered before, the second ledger state is considered after. Returns the second ledger state.
noNewTickingDiffs ∷ ∀ l blk (any ∷ MapKind). HasLedgerTables l blk ⇒ l blk any → l blk DiffMK Source #
Replace tables with an empty diff. Can be used to specify that a ledger state tick produces no new UTXO entries.
valuesAsDiffs ∷ HasLedgerTables l blk ⇒ l blk ValuesMK → l blk DiffMK Source #
Promote values to diffs, for cases in which all existing values must be considered diffs. In particular this is used when populating the ledger tables for the first time.
Combining diffs
prependDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk DiffMK → l' blk DiffMK → l' blk DiffMK Source #
Prepend the diffs from l1 to l2. Returns l2.
Operations on TrackingMK
Augment
attachAndApplyDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → l' blk TrackingMK Source #
Apply the differences from the first ledger state to the values of the
second ledger state. Returns the second ledger state with a TrackingMK of
the final values and all the diffs.
attachEmptyDiffs ∷ HasLedgerTables l blk ⇒ l blk ValuesMK → l blk TrackingMK Source #
Make a TrackingMK with empty diffs.
prependTrackingDiffs ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk TrackingMK → l' blk TrackingMK → l' blk TrackingMK Source #
Prepend tracking diffs from the first ledger state to the tracking diffs from the second ledger state. Keep the tracking values of the second ledger state. Returns the second ledger state.
PRECONDITION: See rawPrependTrackingDiffs.
Reduce
trackingToDiffs ∷ HasLedgerTables l blk ⇒ l blk TrackingMK → l blk DiffMK Source #
rawTrackingDiffs ∷ TrackingMK k v → DiffMK k v Source #
trackingToValues ∷ HasLedgerTables l blk ⇒ l blk TrackingMK → l blk ValuesMK Source #
Union values
unionValues ∷ Ord k ⇒ ValuesMK k v → ValuesMK k v → ValuesMK k v Source #
For this first UTxO-HD iteration, there can't be two keys with different values on the tables, thus there will never be conflicting collisions.
Exposed for cardano-api
Testing
applyDiffs' ∷ (HasLedgerTables l blk, HasLedgerTables l' blk) ⇒ l blk ValuesMK → l' blk DiffMK → LedgerTables blk ValuesMK Source #
Apply diffs from the second ledger state to the values of the first ledger state. Returns ledger tables.
rawAttachAndApplyDiffs ∷ Ord k ⇒ ValuesMK k v → DiffMK k v → TrackingMK k v Source #
rawCalculateDifference ∷ (Ord k, Eq v) ⇒ ValuesMK k v → ValuesMK k v → TrackingMK k v Source #