From 182cdb489b48b8dedbefae670bd578970917d515 Mon Sep 17 00:00:00 2001 From: Kostas Dermentzis Date: Wed, 4 Sep 2024 22:43:49 +0300 Subject: [PATCH] Take less snapshots during ledger replay --- cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs b/cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs index 8df2f9a65..c0875e511 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs @@ -332,10 +332,12 @@ storeSnapshotAndCleanupMaybe env oldState appResult blkNo isCons syncState = case maybeFromStrict (apNewEpoch appResult) of Just newEpoch | newEpochNo <- unEpochNo (Generic.neEpoch newEpoch) - , newEpochNo > 0 -> do - -- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'? - liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1) - pure True + , newEpochNo > 0 + , isCons || (newEpochNo `mod` 10 == 0) || newEpochNo >= 503 -> + do + -- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'? + liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1) + pure True _ -> if timeToSnapshot syncState blkNo && isCons then do