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 @@ -305,7 +305,14 @@ data TestInternals m l blk = TestInternals
305
305
{ wipeLedgerDB :: m ()
306
306
, takeSnapshotNOW :: WhereToTakeSnapshot -> Maybe String -> m ()
307
307
, push :: ExtLedgerState blk DiffMK -> m ()
308
+ -- ^ Push a ledger state, and prune the 'LedgerDB' w.r.t. the security parameter.
309
+ --
310
+ -- This does not modify the set of previously applied points.
308
311
, reapplyThenPushNOW :: blk -> m ()
312
+ -- ^ Apply block to the tip ledger state (using reapplication), and prune the
313
+ -- 'LedgerDB' w.r.t. the security parameter.
314
+ --
315
+ -- This does not modify the set of previously applied points.
309
316
, truncateSnapshots :: m ()
310
317
, closeLedgerDB :: m ()
311
318
, getNumLedgerTablesHandles :: m Word64
Original file line number Diff line number Diff line change @@ -215,8 +215,9 @@ mkInternals bss h =
215
215
eFrk <- newForkerAtTarget h reg VolatileTip
216
216
case eFrk of
217
217
Left {} -> error " Unreachable, Volatile tip MUST be in LedgerDB"
218
- Right frk ->
218
+ Right frk -> do
219
219
forkerPush frk st >> atomically (forkerCommit frk) >> forkerClose frk
220
+ getEnv h pruneLedgerSeq
220
221
, reapplyThenPushNOW = \ blk -> getEnv h $ \ env -> withRegistry $ \ reg -> do
221
222
eFrk <- newForkerAtTarget h reg VolatileTip
222
223
case eFrk of
@@ -231,6 +232,7 @@ mkInternals bss h =
231
232
blk
232
233
(st `withLedgerTables` tables)
233
234
forkerPush frk st' >> atomically (forkerCommit frk) >> forkerClose frk
235
+ pruneLedgerSeq env
234
236
, wipeLedgerDB = getEnv h $ destroySnapshots . ldbHasFS
235
237
, closeLedgerDB =
236
238
let LDBHandle tvar = h
@@ -253,6 +255,12 @@ mkInternals bss h =
253
255
InMemoryHandleArgs -> InMemory. takeSnapshot
254
256
LSMHandleArgs x -> absurd x
255
257
258
+ pruneLedgerSeq :: LedgerDBEnv m (ExtLedgerState blk ) blk -> m ()
259
+ pruneLedgerSeq env =
260
+ join $ atomically $ stateTVar (ldbSeq env) $ prune (LedgerDbPruneKeeping k)
261
+ where
262
+ k = ledgerDbCfgSecParam $ ldbCfg env
263
+
256
264
-- | Testing only! Truncate all snapshots in the DB.
257
265
implIntTruncateSnapshots :: MonadThrow m => SomeHasFS m -> m ()
258
266
implIntTruncateSnapshots sfs@ (SomeHasFS fs) = do
You can’t perform that action at this time.
0 commit comments