Browse Source

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.

pruning-mode
CalDescent 3 years ago
parent
commit
c8466a2e7a
  1. 9
      src/main/java/org/qortal/controller/pruning/AtStatesPruner.java

9
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);

Loading…
Cancel
Save