Skip to content

Commit

Permalink
consensus: abstact some query logic over UTxO HD footprints
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrisby authored and jasagredo committed Dec 10, 2024
1 parent f2eb2f5 commit 4033b2d
Showing 1 changed file with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,37 +227,34 @@ instance ( All SingleEraBlock xs
lcfg = configLedger cfg
ei = State.epochInfoLedger lcfg hardForkState

answerBlockQueryLookup
(ExtLedgerCfg cfg)
qry
forker = do
hardForkState <- hardForkLedgerStatePerEra . ledgerState <$> atomically (roforkerGetLedgerState forker)
let ei = State.epochInfoLedger lcfg hardForkState
cfgs = hmap ExtLedgerCfg $ distribTopLevelConfig ei cfg
case qry of
QueryIfCurrent queryIfCurrent ->
interpretQueryIfCurrentLookup
cfgs
queryIfCurrent
forker
where
lcfg = configLedger cfg

answerBlockQueryTraverse
(ExtLedgerCfg cfg)
qry
forker = do
hardForkState <- hardForkLedgerStatePerEra . ledgerState <$> atomically (roforkerGetLedgerState forker)
let ei = State.epochInfoLedger lcfg hardForkState
cfgs = hmap ExtLedgerCfg $ distribTopLevelConfig ei cfg
case qry of
QueryIfCurrent queryIfCurrent ->
interpretQueryIfCurrentTraverse
cfgs
queryIfCurrent
forker
where
lcfg = configLedger cfg
answerBlockQueryLookup cfg (QueryIfCurrent q) =
answerBlockQueryHelper interpretQueryIfCurrentLookup cfg q
answerBlockQueryTraverse cfg (QueryIfCurrent q) =
answerBlockQueryHelper interpretQueryIfCurrentTraverse cfg q

-- | NOT EXPORTED, for footprints other than 'QFNoTables'
answerBlockQueryHelper ::
(MonadSTM m, BlockSupportsHFLedgerQuery xs, CanHardFork xs)
=> ( NP ExtLedgerCfg xs
-> QueryIfCurrent xs footprint result
-> ReadOnlyForker' m (HardForkBlock xs)
-> m (HardForkQueryResult xs result)
)
-> ExtLedgerCfg (HardForkBlock xs)
-> QueryIfCurrent xs footprint result
-> ReadOnlyForker' m (HardForkBlock xs)
-> m (HardForkQueryResult xs result)
answerBlockQueryHelper
f
(ExtLedgerCfg cfg)
qry
forker = do
hardForkState <- hardForkLedgerStatePerEra . ledgerState <$> atomically (roforkerGetLedgerState forker)
let ei = State.epochInfoLedger lcfg hardForkState
cfgs = hmap ExtLedgerCfg $ distribTopLevelConfig ei cfg
f cfgs qry forker
where
lcfg = configLedger cfg

-- | Precondition: the 'ledgerState' and 'headerState' should be from the same
-- era. In practice, this is _always_ the case, unless the 'ExtLedgerState' was
Expand Down

0 comments on commit 4033b2d

Please sign in to comment.