@@ -184,7 +184,7 @@ mkHandleFromValues tables = do
184184pushLedgerDB :: LedgerDB -> CardanoLedgerState -> (LedgerDB , [CardanoLedgerState ])
185185pushLedgerDB db st =
186186 pruneLedgerDb
187- 100
187+ 1
188188 db
189189 { ledgerDbCheckpoints = NE. cons st (ledgerDbCheckpoints db)
190190 }
@@ -444,18 +444,19 @@ storeSnapshotAndCleanupMaybe ::
444444 Bool ->
445445 SyncState ->
446446 IO Bool
447- storeSnapshotAndCleanupMaybe env oldState appResult isCons syncState =
448- case maybeFromStrict (apNewEpoch appResult) of
449- Just newEpoch
450- | newEpochNo <- unEpochNo (Generic. neEpoch newEpoch)
451- , newEpochNo > 0
452- , -- Snapshot every epoch when near tip, every 10 epochs when lagging, or always for epoch >= threshold
453- (isCons && syncState == SyncFollowing ) || (newEpochNo `mod` 10 == 0 ) || newEpochNo >= leSnapshotNearTipEpoch env ->
454- do
455- -- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'?
456- liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1 )
457- pure True
458- _ -> pure False
447+ storeSnapshotAndCleanupMaybe _ _ _ _ _ = pure False
448+ -- storeSnapshotAndCleanupMaybe env oldState appResult isCons syncState =
449+ -- case maybeFromStrict (apNewEpoch appResult) of
450+ -- Just newEpoch
451+ -- | newEpochNo <- unEpochNo (Generic.neEpoch newEpoch)
452+ -- , newEpochNo > 0
453+ -- , -- Snapshot every epoch when near tip, every 10 epochs when lagging, or always for epoch >= threshold
454+ -- (isCons && syncState == SyncFollowing) || (newEpochNo `mod` 10 == 0) || newEpochNo >= leSnapshotNearTipEpoch env ->
455+ -- do
456+ -- -- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'?
457+ -- liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1)
458+ -- pure True
459+ -- _ -> pure False
459460
460461saveCurrentLedgerState :: HasLedgerEnv -> CardanoLedgerState -> Maybe EpochNo -> IO ()
461462saveCurrentLedgerState env lState mEpochNo = do
@@ -984,15 +985,15 @@ tickThenReapplyCheckHash ::
984985tickThenReapplyCheckHash registry cfg block state'@ CardanoLedgerState {.. } =
985986 if blockPrevHash block == Consensus. ledgerTipHash (ledgerState clsState)
986987 then do
987- -- Read the keys this block needs from the handle
988+ -- Create a new handle first, then read from it
989+ (_rk, newHandle) <- duplicate clsTables registry
988990 let keys = Consensus. getBlockKeySets block
989- restrictedTables <- read clsTables clsState keys
991+ restrictedTables <- read newHandle clsState keys
990992 -- Attach the tables to the ledger state and apply the block
991993 let ledgerState' = Consensus. withLedgerTables clsState restrictedTables
992994 newLedgerState =
993995 Consensus. tickThenReapplyLedgerResult Consensus. ComputeLedgerEvents cfg block ledgerState'
994- -- Create a new handle via duplicate + pushDiffs
995- (_rk, newHandle) <- duplicate clsTables registry
996+ -- Push diffs to the new handle
996997 pushDiffs newHandle clsState (Consensus. lrResult newLedgerState)
997998 pure . Right $
998999 fmap
0 commit comments