1
+ {-# LANGUAGE BangPatterns #-}
1
2
{-# LANGUAGE CPP #-}
2
3
{-# LANGUAGE DataKinds #-}
3
4
{-# LANGUAGE DeriveAnyClass #-}
@@ -210,8 +211,9 @@ mkInternals bss h =
210
211
eFrk <- newForkerAtTarget h reg VolatileTip
211
212
case eFrk of
212
213
Left {} -> error " Unreachable, Volatile tip MUST be in LedgerDB"
213
- Right frk ->
214
+ Right frk -> do
214
215
forkerPush frk st >> atomically (forkerCommit frk) >> forkerClose frk
216
+ getEnv h pruneLedgerSeq
215
217
, reapplyThenPushNOW = \ blk -> getEnv h $ \ env -> withRegistry $ \ reg -> do
216
218
eFrk <- newForkerAtTarget h reg VolatileTip
217
219
case eFrk of
@@ -226,6 +228,7 @@ mkInternals bss h =
226
228
blk
227
229
(st `withLedgerTables` tables)
228
230
forkerPush frk st' >> atomically (forkerCommit frk) >> forkerClose frk
231
+ pruneLedgerSeq env
229
232
, wipeLedgerDB = getEnv h $ destroySnapshots . ldbHasFS
230
233
, closeLedgerDB =
231
234
let LDBHandle tvar = h
@@ -244,6 +247,12 @@ mkInternals bss h =
244
247
InMemoryHandleArgs -> InMemory. takeSnapshot
245
248
LSMHandleArgs x -> absurd x
246
249
250
+ pruneLedgerSeq :: LedgerDBEnv m (ExtLedgerState blk ) blk -> m ()
251
+ pruneLedgerSeq env =
252
+ join $ atomically $ stateTVar (ldbSeq env) $ prune (LedgerDbPruneKeeping k)
253
+ where
254
+ k = ledgerDbCfgSecParam $ ldbCfg env
255
+
247
256
-- | Testing only! Truncate all snapshots in the DB.
248
257
implIntTruncateSnapshots :: MonadThrow m => SomeHasFS m -> m ()
249
258
implIntTruncateSnapshots sfs@ (SomeHasFS fs) = do
@@ -412,8 +421,8 @@ implTryTakeSnapshot bss env mTime nrBlocks =
412
421
-- periodically flush the accumulated differences to the disk. However, in the
413
422
-- second version there is no need to do so, and because of that, this function
414
423
-- does nothing in this case.
415
- implTryFlush :: Applicative m => LedgerDBEnv m l blk -> m ()
416
- implTryFlush _ = pure ()
424
+ implTryFlush :: ( Applicative m , GetTip l ) => LedgerDBEnv m l blk -> m ()
425
+ implTryFlush env = pure ()
417
426
418
427
implCloseDB :: IOLike m => LedgerDBHandle m l blk -> m ()
419
428
implCloseDB (LDBHandle varState) = do
0 commit comments