File tree 2 files changed +16
-1
lines changed
ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB
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
}
Original file line number Diff line number Diff line change @@ -210,8 +210,9 @@ mkInternals bss h =
210
210
eFrk <- newForkerAtTarget h reg VolatileTip
211
211
case eFrk of
212
212
Left {} -> error " Unreachable, Volatile tip MUST be in LedgerDB"
213
- Right frk ->
213
+ Right frk -> do
214
214
forkerPush frk st >> atomically (forkerCommit frk) >> forkerClose frk
215
+ getEnv h pruneLedgerSeq
215
216
, reapplyThenPushNOW = \ blk -> getEnv h $ \ env -> withRegistry $ \ reg -> do
216
217
eFrk <- newForkerAtTarget h reg VolatileTip
217
218
case eFrk of
@@ -226,6 +227,7 @@ mkInternals bss h =
226
227
blk
227
228
(st `withLedgerTables` tables)
228
229
forkerPush frk st' >> atomically (forkerCommit frk) >> forkerClose frk
230
+ pruneLedgerSeq env
229
231
, wipeLedgerDB = getEnv h $ destroySnapshots . ldbHasFS
230
232
, closeLedgerDB =
231
233
let LDBHandle tvar = h
@@ -244,6 +246,12 @@ mkInternals bss h =
244
246
InMemoryHandleArgs -> InMemory. takeSnapshot
245
247
LSMHandleArgs x -> absurd x
246
248
249
+ pruneLedgerSeq :: LedgerDBEnv m (ExtLedgerState blk ) blk -> m ()
250
+ pruneLedgerSeq env =
251
+ join $ atomically $ stateTVar (ldbSeq env) $ prune (LedgerDbPruneKeeping k)
252
+ where
253
+ k = ledgerDbCfgSecParam $ ldbCfg env
254
+
247
255
-- | Testing only! Truncate all snapshots in the DB.
248
256
implIntTruncateSnapshots :: MonadThrow m => SomeHasFS m -> m ()
249
257
implIntTruncateSnapshots sfs@ (SomeHasFS fs) = do
You can’t perform that action at this time.
0 commit comments