File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,14 @@ data TestInternals m l blk = TestInternals
304304 { wipeLedgerDB :: m ()
305305 , takeSnapshotNOW :: WhereToTakeSnapshot -> Maybe String -> m ()
306306 , push :: ExtLedgerState blk DiffMK -> m ()
307+ -- ^ Push a ledger state, and prune the 'LedgerDB' w.r.t. the security parameter.
308+ --
309+ -- This does not modify the set of previously applied points.
307310 , reapplyThenPushNOW :: blk -> m ()
311+ -- ^ Apply block to the tip ledger state (using reapplication), and prune the
312+ -- 'LedgerDB' w.r.t. the security parameter.
313+ --
314+ -- This does not modify the set of previously applied points.
308315 , truncateSnapshots :: m ()
309316 , closeLedgerDB :: m ()
310317 , getNumLedgerTablesHandles :: m Word64
Original file line number Diff line number Diff line change @@ -212,8 +212,9 @@ mkInternals bss h =
212212 eFrk <- newForkerAtTarget h reg VolatileTip
213213 case eFrk of
214214 Left {} -> error " Unreachable, Volatile tip MUST be in LedgerDB"
215- Right frk ->
215+ Right frk -> do
216216 forkerPush frk st >> atomically (forkerCommit frk) >> forkerClose frk
217+ getEnv h pruneLedgerSeq
217218 , reapplyThenPushNOW = \ blk -> getEnv h $ \ env -> withRegistry $ \ reg -> do
218219 eFrk <- newForkerAtTarget h reg VolatileTip
219220 case eFrk of
@@ -228,6 +229,7 @@ mkInternals bss h =
228229 blk
229230 (st `withLedgerTables` tables)
230231 forkerPush frk st' >> atomically (forkerCommit frk) >> forkerClose frk
232+ pruneLedgerSeq env
231233 , wipeLedgerDB = getEnv h $ destroySnapshots . ldbHasFS
232234 , closeLedgerDB =
233235 let LDBHandle tvar = h
@@ -250,6 +252,12 @@ mkInternals bss h =
250252 InMemoryHandleArgs -> InMemory. takeSnapshot
251253 LSMHandleArgs x -> absurd x
252254
255+ pruneLedgerSeq :: LedgerDBEnv m (ExtLedgerState blk ) blk -> m ()
256+ pruneLedgerSeq env =
257+ join $ atomically $ stateTVar (ldbSeq env) $ prune (LedgerDbPruneKeeping k)
258+ where
259+ k = ledgerDbCfgSecParam $ ldbCfg env
260+
253261-- | Testing only! Truncate all snapshots in the DB.
254262implIntTruncateSnapshots :: MonadThrow m => SomeHasFS m -> m ()
255263implIntTruncateSnapshots sfs@ (SomeHasFS fs) = do
You can’t perform that action at this time.
0 commit comments