Skip to content

Commit

Permalink
Replace explicit if with a when function
Browse files Browse the repository at this point in the history
  • Loading branch information
EncodePanda committed Sep 22, 2021
1 parent 87d44cb commit 274a415
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ouroboros-consensus-cardano/tools/db-analyser/Analysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,14 @@ storeLedgerStateAt slotNo (AnalysisEnv { db, registry, initLedger, cfg, hasFS })
let ledgerCfg = ExtLedgerCfg cfg
appliedResult = tickThenApplyLedgerResult ledgerCfg blk oldLedger
newLedger = either (error . show) lrResult $ runExcept $ appliedResult
if slotNo == blockSlot blk then
storeAndReturnNewLedger blk newLedger
else return newLedger
when (slotNo == blockSlot blk) $ storeLedgerState blk newLedger
return newLedger

storeAndReturnNewLedger ::
storeLedgerState ::
blk
-> ExtLedgerState blk
-> IO (ExtLedgerState blk)
storeAndReturnNewLedger blk ledgerState = do
-> IO ()
storeLedgerState blk ledgerState = do
let snapshot = DiskSnapshot
(unSlotNo $ blockSlot blk)
(Just $ "db-analyser")
Expand All @@ -223,7 +222,6 @@ storeLedgerStateAt slotNo (AnalysisEnv { db, registry, initLedger, cfg, hasFS })
, show (blockSlot blk)
, show (blockHash blk)
]
pure ledgerState

encLedger :: ExtLedgerState blk -> Encoding
encLedger =
Expand Down

0 comments on commit 274a415

Please sign in to comment.