From 01d66212daacd99ddb1f473268aebfbb5733563c Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 22 Aug 2021 15:20:11 +0100 Subject: [PATCH] Updated AT states pruner as it previously relied on blocks being present in the db to make decisions. As a side effect, this now prunes ATs up the the pruneBlockLimit too, rather than keeping the last 35 days or so. Will review this later but I don't think we will need the missing ones. --- .../org/qortal/controller/pruning/AtStatesPruner.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/qortal/controller/pruning/AtStatesPruner.java b/src/main/java/org/qortal/controller/pruning/AtStatesPruner.java index 37f0cd74..4268f98c 100644 --- a/src/main/java/org/qortal/controller/pruning/AtStatesPruner.java +++ b/src/main/java/org/qortal/controller/pruning/AtStatesPruner.java @@ -49,12 +49,9 @@ public class AtStatesPruner implements Runnable { if (Controller.getInstance().isSynchronizing()) continue; - long currentPrunableTimestamp = NTP.getTime() - Settings.getInstance().getAtStatesMaxLifetime(); - // We want to keep AT states near the tip of our copy of blockchain so we can process/orphan nearby blocks - long chainPrunableTimestamp = chainTip.getTimestamp() - Settings.getInstance().getAtStatesMaxLifetime(); - - long upperPrunableTimestamp = Math.min(currentPrunableTimestamp, chainPrunableTimestamp); - int upperPrunableHeight = repository.getBlockRepository().getHeightFromTimestamp(upperPrunableTimestamp); + // Prune AT states for all blocks up until our latest minus pruneBlockLimit + final int ourLatestHeight = chainTip.getHeight(); + final int upperPrunableHeight = ourLatestHeight - Settings.getInstance().getPruneBlockLimit(); int upperBatchHeight = pruneStartHeight + Settings.getInstance().getAtStatesPruneBatchSize(); int upperPruneHeight = Math.min(upperBatchHeight, upperPrunableHeight);