{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Ledger.Abstract (
Validated
, ApplyBlock (..)
, ComputeLedgerEvents (..)
, UpdateLedger
, defaultApplyBlockLedgerResult
, defaultReapplyBlockLedgerResult
, applyLedgerBlock
, foldLedger
, reapplyLedgerBlock
, refoldLedger
, tickThenApply
, tickThenApplyLedgerResult
, tickThenReapply
, tickThenReapplyLedgerResult
, ledgerTipHash
, ledgerTipPoint
, ledgerTipSlot
, module Ouroboros.Consensus.Ledger.Basics
) where
import Control.Monad.Except
import qualified Control.State.Transition.Extended as STS
import Data.Kind (Type)
import GHC.Stack (HasCallStack)
import Ouroboros.Consensus.Block.Abstract
import Ouroboros.Consensus.Ledger.Basics
import Ouroboros.Consensus.Ledger.Tables.Utils
import Ouroboros.Consensus.Ticked
import Ouroboros.Consensus.Util
data family Validated x :: Type
class ( IsLedger l
, HeaderHash l ~ HeaderHash blk
, HasHeader blk
, HasHeader (Header blk)
, HasLedgerTables l
, HasLedgerTables (Ticked l)
) => ApplyBlock l blk where
applyBlockLedgerResultWithValidation ::
HasCallStack
=> STS.ValidationPolicy
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
applyBlockLedgerResult ::
HasCallStack
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
reapplyBlockLedgerResult ::
HasCallStack
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
getBlockKeySets :: blk -> LedgerTables l KeysMK
defaultApplyBlockLedgerResult ::
(HasCallStack, ApplyBlock l blk)
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
defaultApplyBlockLedgerResult :: forall (l :: LedgerStateKind) blk.
(HasCallStack, ApplyBlock l blk) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
defaultApplyBlockLedgerResult =
ValidationPolicy
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ValidationPolicy
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
applyBlockLedgerResultWithValidation ValidationPolicy
STS.ValidateAll
defaultReapplyBlockLedgerResult ::
(HasCallStack, ApplyBlock l blk)
=> (LedgerErr l -> LedgerResult l (l DiffMK))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
defaultReapplyBlockLedgerResult :: forall (l :: LedgerStateKind) blk.
(HasCallStack, ApplyBlock l blk) =>
(LedgerErr l -> LedgerResult l (l DiffMK))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
defaultReapplyBlockLedgerResult LedgerErr l -> LedgerResult l (l DiffMK)
throwReapplyError =
((LedgerErr l -> LedgerResult l (l DiffMK))
-> (LedgerResult l (l DiffMK) -> LedgerResult l (l DiffMK))
-> Either (LedgerErr l) (LedgerResult l (l DiffMK))
-> LedgerResult l (l DiffMK)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either LedgerErr l -> LedgerResult l (l DiffMK)
throwReapplyError LedgerResult l (l DiffMK) -> LedgerResult l (l DiffMK)
forall a. a -> a
id (Either (LedgerErr l) (LedgerResult l (l DiffMK))
-> LedgerResult l (l DiffMK))
-> (Except (LedgerErr l) (LedgerResult l (l DiffMK))
-> Either (LedgerErr l) (LedgerResult l (l DiffMK)))
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
-> LedgerResult l (l DiffMK)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Except (LedgerErr l) (LedgerResult l (l DiffMK))
-> Either (LedgerErr l) (LedgerResult l (l DiffMK))
forall e a. Except e a -> Either e a
runExcept)
(Except (LedgerErr l) (LedgerResult l (l DiffMK))
-> LedgerResult l (l DiffMK))
-> (ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK)))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
forall y z x0 x1 x2 x3.
(y -> z)
-> (x0 -> x1 -> x2 -> x3 -> y) -> x0 -> x1 -> x2 -> x3 -> z
...: ValidationPolicy
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ValidationPolicy
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
applyBlockLedgerResultWithValidation ValidationPolicy
STS.ValidateNone
class ApplyBlock (LedgerState blk) blk => UpdateLedger blk
applyLedgerBlock ::
forall l blk.
(ApplyBlock l blk, HasCallStack)
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (l DiffMK)
applyLedgerBlock :: forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (l DiffMK)
applyLedgerBlock = (LedgerResult l (l DiffMK) -> l DiffMK)
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
-> ExceptT (LedgerErr l) Identity (l DiffMK)
forall a b.
(a -> b)
-> ExceptT (LedgerErr l) Identity a
-> ExceptT (LedgerErr l) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LedgerResult l (l DiffMK) -> l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult (ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
-> ExceptT (LedgerErr l) Identity (l DiffMK))
-> (ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK)))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> ExceptT (LedgerErr l) Identity (l DiffMK)
forall y z x0 x1 x2 x3.
(y -> z)
-> (x0 -> x1 -> x2 -> x3 -> y) -> x0 -> x1 -> x2 -> x3 -> z
...: ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
applyBlockLedgerResult
reapplyLedgerBlock ::
forall l blk.
(ApplyBlock l blk, HasCallStack)
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> l DiffMK
reapplyLedgerBlock :: forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l -> blk -> Ticked l ValuesMK -> l DiffMK
reapplyLedgerBlock = LedgerResult l (l DiffMK) -> l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult (LedgerResult l (l DiffMK) -> l DiffMK)
-> (ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> l DiffMK
forall y z x0 x1 x2 x3.
(y -> z)
-> (x0 -> x1 -> x2 -> x3 -> y) -> x0 -> x1 -> x2 -> x3 -> z
...: ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
reapplyBlockLedgerResult
tickThenApplyLedgerResult ::
ApplyBlock l blk
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
tickThenApplyLedgerResult :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
tickThenApplyLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk l ValuesMK
l = do
let lrTick :: LedgerResult l (Ticked l DiffMK)
lrTick = ComputeLedgerEvents
-> LedgerCfg l
-> SlotNo
-> l EmptyMK
-> LedgerResult l (Ticked l DiffMK)
forall (l :: LedgerStateKind).
IsLedger l =>
ComputeLedgerEvents
-> LedgerCfg l
-> SlotNo
-> l EmptyMK
-> LedgerResult l (Ticked l DiffMK)
applyChainTickLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg (blk -> SlotNo
forall b. HasHeader b => b -> SlotNo
blockSlot blk
blk) (l ValuesMK -> l EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables l ValuesMK
l)
lrBlock <- ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
applyBlockLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk (l ValuesMK
-> LedgerTables l KeysMK -> Ticked l DiffMK -> Ticked l ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> LedgerTables l KeysMK -> l' DiffMK -> l' ValuesMK
applyDiffForKeys l ValuesMK
l (blk -> LedgerTables l KeysMK
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
blk -> LedgerTables l KeysMK
getBlockKeySets blk
blk) (LedgerResult l (Ticked l DiffMK) -> Ticked l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult LedgerResult l (Ticked l DiffMK)
lrTick))
pure LedgerResult {
lrEvents = lrEvents lrTick <> lrEvents lrBlock
, lrResult = prependDiffs (lrResult lrTick) (lrResult lrBlock)
}
tickThenReapplyLedgerResult ::
forall l blk.
ApplyBlock l blk
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> LedgerResult l (l DiffMK)
tickThenReapplyLedgerResult :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l -> blk -> l ValuesMK -> LedgerResult l (l DiffMK)
tickThenReapplyLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk l ValuesMK
l =
let lrTick :: LedgerResult l (Ticked l DiffMK)
lrTick = ComputeLedgerEvents
-> LedgerCfg l
-> SlotNo
-> l EmptyMK
-> LedgerResult l (Ticked l DiffMK)
forall (l :: LedgerStateKind).
IsLedger l =>
ComputeLedgerEvents
-> LedgerCfg l
-> SlotNo
-> l EmptyMK
-> LedgerResult l (Ticked l DiffMK)
applyChainTickLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg (blk -> SlotNo
forall b. HasHeader b => b -> SlotNo
blockSlot blk
blk) (l ValuesMK -> l EmptyMK
forall (l :: LedgerStateKind) (mk :: MapKind).
HasLedgerTables l =>
l mk -> l EmptyMK
forgetLedgerTables l ValuesMK
l)
lrBlock :: LedgerResult l (l DiffMK)
lrBlock = ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
forall (l :: LedgerStateKind) blk.
(ApplyBlock l blk, HasCallStack) =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> Ticked l ValuesMK
-> LedgerResult l (l DiffMK)
reapplyBlockLedgerResult ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk (l ValuesMK
-> LedgerTables l KeysMK -> Ticked l DiffMK -> Ticked l ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> LedgerTables l KeysMK -> l' DiffMK -> l' ValuesMK
applyDiffForKeys l ValuesMK
l (blk -> LedgerTables l KeysMK
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
blk -> LedgerTables l KeysMK
getBlockKeySets blk
blk) (LedgerResult l (Ticked l DiffMK) -> Ticked l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult LedgerResult l (Ticked l DiffMK)
lrTick))
in LedgerResult {
lrEvents :: [AuxLedgerEvent l]
lrEvents = LedgerResult l (Ticked l DiffMK) -> [AuxLedgerEvent l]
forall (l :: LedgerStateKind) a.
LedgerResult l a -> [AuxLedgerEvent l]
lrEvents LedgerResult l (Ticked l DiffMK)
lrTick [AuxLedgerEvent l] -> [AuxLedgerEvent l] -> [AuxLedgerEvent l]
forall a. Semigroup a => a -> a -> a
<> LedgerResult l (l DiffMK) -> [AuxLedgerEvent l]
forall (l :: LedgerStateKind) a.
LedgerResult l a -> [AuxLedgerEvent l]
lrEvents LedgerResult l (l DiffMK)
lrBlock
, lrResult :: l DiffMK
lrResult = Ticked l DiffMK -> l DiffMK -> l DiffMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l DiffMK -> l' DiffMK -> l' DiffMK
prependDiffs (LedgerResult l (Ticked l DiffMK) -> Ticked l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult LedgerResult l (Ticked l DiffMK)
lrTick) (LedgerResult l (l DiffMK) -> l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult LedgerResult l (l DiffMK)
lrBlock)
}
tickThenApply ::
forall l blk.
ApplyBlock l blk
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (l DiffMK)
tickThenApply :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (l DiffMK)
tickThenApply = (LedgerResult l (l DiffMK) -> l DiffMK)
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
-> ExceptT (LedgerErr l) Identity (l DiffMK)
forall a b.
(a -> b)
-> ExceptT (LedgerErr l) Identity a
-> ExceptT (LedgerErr l) Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LedgerResult l (l DiffMK) -> l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult (ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
-> ExceptT (LedgerErr l) Identity (l DiffMK))
-> (ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK)))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> ExceptT (LedgerErr l) Identity (l DiffMK)
forall y z x0 x1 x2 x3.
(y -> z)
-> (x0 -> x1 -> x2 -> x3 -> y) -> x0 -> x1 -> x2 -> x3 -> z
...: ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> ExceptT (LedgerErr l) Identity (LedgerResult l (l DiffMK))
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (LedgerResult l (l DiffMK))
tickThenApplyLedgerResult
tickThenReapply ::
forall l blk.
ApplyBlock l blk
=> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> l DiffMK
tickThenReapply :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents -> LedgerCfg l -> blk -> l ValuesMK -> l DiffMK
tickThenReapply = LedgerResult l (l DiffMK) -> l DiffMK
forall (l :: LedgerStateKind) a. LedgerResult l a -> a
lrResult (LedgerResult l (l DiffMK) -> l DiffMK)
-> (ComputeLedgerEvents
-> LedgerCfg l -> blk -> l ValuesMK -> LedgerResult l (l DiffMK))
-> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> l DiffMK
forall y z x0 x1 x2 x3.
(y -> z)
-> (x0 -> x1 -> x2 -> x3 -> y) -> x0 -> x1 -> x2 -> x3 -> z
...: ComputeLedgerEvents
-> LedgerCfg l -> blk -> l ValuesMK -> LedgerResult l (l DiffMK)
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l -> blk -> l ValuesMK -> LedgerResult l (l DiffMK)
tickThenReapplyLedgerResult
foldLedger ::
ApplyBlock l blk
=> ComputeLedgerEvents -> LedgerCfg l -> [blk] -> l ValuesMK -> Except (LedgerErr l) (l ValuesMK)
foldLedger :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l
-> [blk]
-> l ValuesMK
-> Except (LedgerErr l) (l ValuesMK)
foldLedger ComputeLedgerEvents
evs LedgerCfg l
cfg = (blk -> l ValuesMK -> ExceptT (LedgerErr l) Identity (l ValuesMK))
-> [blk]
-> l ValuesMK
-> ExceptT (LedgerErr l) Identity (l ValuesMK)
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m b) -> [a] -> b -> m b
repeatedlyM (\blk
blk l ValuesMK
state -> l ValuesMK -> LedgerTables l KeysMK -> l DiffMK -> l ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> LedgerTables l KeysMK -> l' DiffMK -> l' ValuesMK
applyDiffForKeys l ValuesMK
state (blk -> LedgerTables l KeysMK
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
blk -> LedgerTables l KeysMK
getBlockKeySets blk
blk) (l DiffMK -> l ValuesMK)
-> ExceptT (LedgerErr l) Identity (l DiffMK)
-> ExceptT (LedgerErr l) Identity (l ValuesMK)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> ExceptT (LedgerErr l) Identity (l DiffMK)
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l
-> blk
-> l ValuesMK
-> Except (LedgerErr l) (l DiffMK)
tickThenApply ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk l ValuesMK
state)
refoldLedger ::
ApplyBlock l blk
=> ComputeLedgerEvents -> LedgerCfg l -> [blk] -> l ValuesMK -> l ValuesMK
refoldLedger :: forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents
-> LedgerCfg l -> [blk] -> l ValuesMK -> l ValuesMK
refoldLedger ComputeLedgerEvents
evs LedgerCfg l
cfg = (blk -> l ValuesMK -> l ValuesMK)
-> [blk] -> l ValuesMK -> l ValuesMK
forall a b. (a -> b -> b) -> [a] -> b -> b
repeatedly (\blk
blk l ValuesMK
state -> l ValuesMK -> LedgerTables l KeysMK -> l DiffMK -> l ValuesMK
forall (l :: LedgerStateKind) (l' :: LedgerStateKind).
(SameUtxoTypes l l', HasLedgerTables l, HasLedgerTables l') =>
l ValuesMK -> LedgerTables l KeysMK -> l' DiffMK -> l' ValuesMK
applyDiffForKeys l ValuesMK
state (blk -> LedgerTables l KeysMK
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
blk -> LedgerTables l KeysMK
getBlockKeySets blk
blk) (l DiffMK -> l ValuesMK) -> l DiffMK -> l ValuesMK
forall a b. (a -> b) -> a -> b
$ ComputeLedgerEvents -> LedgerCfg l -> blk -> l ValuesMK -> l DiffMK
forall (l :: LedgerStateKind) blk.
ApplyBlock l blk =>
ComputeLedgerEvents -> LedgerCfg l -> blk -> l ValuesMK -> l DiffMK
tickThenReapply ComputeLedgerEvents
evs LedgerCfg l
cfg blk
blk l ValuesMK
state)
ledgerTipPoint ::
UpdateLedger blk
=> LedgerState blk mk -> Point blk
ledgerTipPoint :: forall blk (mk :: MapKind).
UpdateLedger blk =>
LedgerState blk mk -> Point blk
ledgerTipPoint = Point (LedgerState blk) -> Point blk
forall {k1} {k2} (b :: k1) (b' :: k2).
Coercible (HeaderHash b) (HeaderHash b') =>
Point b -> Point b'
castPoint (Point (LedgerState blk) -> Point blk)
-> (LedgerState blk mk -> Point (LedgerState blk))
-> LedgerState blk mk
-> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState blk mk -> Point (LedgerState blk)
forall (mk :: MapKind).
LedgerState blk mk -> Point (LedgerState blk)
forall (l :: LedgerStateKind) (mk :: MapKind).
GetTip l =>
l mk -> Point l
getTip
ledgerTipHash ::
UpdateLedger blk
=> LedgerState blk mk -> ChainHash blk
ledgerTipHash :: forall blk (mk :: MapKind).
UpdateLedger blk =>
LedgerState blk mk -> ChainHash blk
ledgerTipHash = Point blk -> ChainHash blk
forall {k} (block :: k). Point block -> ChainHash block
pointHash (Point blk -> ChainHash blk)
-> (LedgerState blk mk -> Point blk)
-> LedgerState blk mk
-> ChainHash blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState blk mk -> Point blk
forall blk (mk :: MapKind).
UpdateLedger blk =>
LedgerState blk mk -> Point blk
ledgerTipPoint
ledgerTipSlot ::
UpdateLedger blk
=> LedgerState blk mk -> WithOrigin SlotNo
ledgerTipSlot :: forall blk (mk :: MapKind).
UpdateLedger blk =>
LedgerState blk mk -> WithOrigin SlotNo
ledgerTipSlot = Point blk -> WithOrigin SlotNo
forall {k} (block :: k). Point block -> WithOrigin SlotNo
pointSlot (Point blk -> WithOrigin SlotNo)
-> (LedgerState blk mk -> Point blk)
-> LedgerState blk mk
-> WithOrigin SlotNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LedgerState blk mk -> Point blk
forall blk (mk :: MapKind).
UpdateLedger blk =>
LedgerState blk mk -> Point blk
ledgerTipPoint