Skip to content

Commit ee92daa

Browse files
committed
db-analyser: make storeLedgerState less confusing
Just read the tip slot off the LedgerDB directly
1 parent f52e16c commit ee92daa

File tree

1 file changed

+5
-6
lines changed
  • ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser

1 file changed

+5
-6
lines changed

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Analysis.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,14 @@ storeLedgerStateAt slotNo ledgerAppMode env = do
395395
case runExcept $ tickThenXApply OmitLedgerEvents ledgerCfg blk (oldLedger `withLedgerTables` tbs) of
396396
Right newLedger -> do
397397
LedgerDB.push internal newLedger
398-
when (blockSlot blk >= slotNo) $ storeLedgerState newLedger
398+
when (blockSlot blk >= slotNo) storeLedgerState
399399
when (blockSlot blk > slotNo) $ issueWarning blk
400400
when ((unBlockNo $ blockNo blk) `mod` 1000 == 0) $ reportProgress blk
401401
LedgerDB.tryFlush initLedgerDB
402402
return (continue blk, ())
403403
Left err -> do
404404
traceWith tracer $ LedgerErrorEvent (blockPoint blk) err
405-
storeLedgerState (oldLedger `withLedgerTables` tbs)
405+
storeLedgerState
406406
pure (Stop, ())
407407

408408
tickThenXApply = case ledgerAppMode of
@@ -419,14 +419,13 @@ storeLedgerStateAt slotNo ledgerAppMode env = do
419419
reportProgress blk = let event = BlockSlotEvent (blockNo blk) (blockSlot blk) (blockHash blk)
420420
in traceWith tracer event
421421

422-
storeLedgerState :: ExtLedgerState blk mk -> IO ()
423-
storeLedgerState ledgerState = case pointSlot pt of
422+
storeLedgerState :: IO ()
423+
storeLedgerState =
424+
IOLike.atomically (pointSlot <$> LedgerDB.currentPoint initLedgerDB) >>= \case
424425
NotOrigin slot -> do
425426
LedgerDB.takeSnapshotNOW internal LedgerDB.TakeAtVolatileTip (Just "db-analyser")
426427
traceWith tracer $ SnapshotStoredEvent slot
427428
Origin -> pure ()
428-
where
429-
pt = headerStatePoint $ headerState ledgerState
430429

431430
countBlocks ::
432431
forall blk .

0 commit comments

Comments
 (0)