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 @@ -213,8 +213,9 @@ mkInternals bss h =
213
213
eFrk <- newForkerAtTarget h reg VolatileTip
214
214
case eFrk of
215
215
Left {} -> error " Unreachable, Volatile tip MUST be in LedgerDB"
216
- Right frk ->
216
+ Right frk -> do
217
217
forkerPush frk st >> atomically (forkerCommit frk) >> forkerClose frk
218
+ getEnv h pruneLedgerSeq
218
219
, reapplyThenPushNOW = \ blk -> getEnv h $ \ env -> withRegistry $ \ reg -> do
219
220
eFrk <- newForkerAtTarget h reg VolatileTip
220
221
case eFrk of
@@ -229,6 +230,7 @@ mkInternals bss h =
229
230
blk
230
231
(st `withLedgerTables` tables)
231
232
forkerPush frk st' >> atomically (forkerCommit frk) >> forkerClose frk
233
+ pruneLedgerSeq env
232
234
, wipeLedgerDB = getEnv h $ destroySnapshots . ldbHasFS
233
235
, closeLedgerDB =
234
236
let LDBHandle tvar = h
@@ -251,6 +253,12 @@ mkInternals bss h =
251
253
InMemoryHandleArgs -> InMemory. takeSnapshot
252
254
LSMHandleArgs x -> absurd x
253
255
256
+ pruneLedgerSeq :: LedgerDBEnv m (ExtLedgerState blk ) blk -> m ()
257
+ pruneLedgerSeq env =
258
+ join $ atomically $ stateTVar (ldbSeq env) $ prune (LedgerDbPruneKeeping k)
259
+ where
260
+ k = ledgerDbCfgSecParam $ ldbCfg env
261
+
254
262
-- | Testing only! Truncate all snapshots in the DB.
255
263
implIntTruncateSnapshots :: MonadThrow m => SomeHasFS m -> m ()
256
264
implIntTruncateSnapshots sfs@ (SomeHasFS fs) = do
You can’t perform that action at this time.
0 commit comments