diff --git a/src/main/java/org/qortal/controller/repository/BlockArchiver.java b/src/main/java/org/qortal/controller/repository/BlockArchiver.java index f7bafe7d..aab4b4fa 100644 --- a/src/main/java/org/qortal/controller/repository/BlockArchiver.java +++ b/src/main/java/org/qortal/controller/repository/BlockArchiver.java @@ -35,7 +35,7 @@ public class BlockArchiver implements Runnable { while (!Controller.isStopping()) { repository.discardChanges(); - final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository, true); + final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository); Thread.sleep(Settings.getInstance().getArchiveInterval()); diff --git a/src/main/java/org/qortal/repository/BlockArchiveWriter.java b/src/main/java/org/qortal/repository/BlockArchiveWriter.java index 4aeb1a32..59d07072 100644 --- a/src/main/java/org/qortal/repository/BlockArchiveWriter.java +++ b/src/main/java/org/qortal/repository/BlockArchiveWriter.java @@ -42,34 +42,16 @@ public class BlockArchiveWriter { this.repository = repository; } - public static int getMaxArchiveHeight(Repository repository, boolean useMaximumDuplicatedLimit) throws DataException { + public static int getMaxArchiveHeight(Repository repository) throws DataException { // We must only archive trimmed blocks, or the archive will grow far too large final int accountSignaturesTrimStartHeight = repository.getBlockRepository().getOnlineAccountsSignaturesTrimHeight(); final int atTrimStartHeight = repository.getATRepository().getAtTrimHeight(); final int trimStartHeight = Math.min(accountSignaturesTrimStartHeight, atTrimStartHeight); - - // In some cases we want to restrict the upper height of the archiver to save space - if (useMaximumDuplicatedLimit) { - // To save on disk space, it's best to not allow the archiver to get too far ahead of the pruner - // This reduces the amount of data that is held twice during the transition - final int blockPruneStartHeight = repository.getBlockRepository().getBlockPruneHeight(); - final int atPruneStartHeight = repository.getATRepository().getAtPruneHeight(); - final int pruneStartHeight = Math.min(blockPruneStartHeight, atPruneStartHeight); - final int maximumDuplicatedBlocks = Settings.getInstance().getMaxDuplicatedBlocksWhenArchiving(); - - // To summarize the above: - // - We must never archive anything greater than or equal to trimStartHeight - // - We should avoid archiving anything maximumDuplicatedBlocks higher than pruneStartHeight - return Math.min(trimStartHeight, pruneStartHeight + maximumDuplicatedBlocks); - } - else { - // We don't want to apply the maximum duplicated limit - return trimStartHeight; - } + return trimStartHeight - 1; // subtract 1 because these values represent the first _untrimmed_ block } - public static boolean isArchiverUpToDate(Repository repository, boolean useMaximumDuplicatedLimit) throws DataException { - final int maxArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository, useMaximumDuplicatedLimit); + public static boolean isArchiverUpToDate(Repository repository) throws DataException { + final int maxArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository); final int actualArchiveHeight = repository.getBlockArchiveRepository().getBlockArchiveHeight(); final float progress = (float)actualArchiveHeight / (float) maxArchiveHeight; LOGGER.info(String.format("maxArchiveHeight: %d, actualArchiveHeight: %d, progress: %f", diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseArchiving.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseArchiving.java index 930da828..7a7b66f3 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseArchiving.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseArchiving.java @@ -41,7 +41,7 @@ public class HSQLDBDatabaseArchiving { LOGGER.info("Building block archive - this process could take a while... (approx. 15 mins on high spec)"); - final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository, false); + final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository); int startHeight = 0; while (!Controller.isStopping()) { diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java index 969c954c..65139743 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java @@ -52,7 +52,7 @@ public class HSQLDBDatabasePruning { // Only proceed if we can see that the archiver has already finished // This way, if the archiver failed for any reason, we can prune once it has had // some opportunities to try again - boolean upToDate = BlockArchiveWriter.isArchiverUpToDate(repository, false); + boolean upToDate = BlockArchiveWriter.isArchiverUpToDate(repository); if (!upToDate) { return false; } @@ -253,7 +253,7 @@ public class HSQLDBDatabasePruning { // Only proceed if we can see that the archiver has already finished // This way, if the archiver failed for any reason, we can prune once it has had // some opportunities to try again - boolean upToDate = BlockArchiveWriter.isArchiverUpToDate(repository, false); + boolean upToDate = BlockArchiveWriter.isArchiverUpToDate(repository); if (!upToDate) { return false; } diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index 82a7aaa0..15ead8e7 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -136,9 +136,6 @@ public class Settings { private boolean archiveEnabled = true; /** How often to attempt archiving (ms). */ private long archiveInterval = 7171L; // milliseconds - /** The maximum number of blocks that can exist in both the - * database and the archive at the same time */ - private int maxDuplicatedBlocksWhenArchiving = 100000; // Peer-to-peer related @@ -599,8 +596,4 @@ public class Settings { return this.archiveInterval; } - public int getMaxDuplicatedBlocksWhenArchiving() { - return this.maxDuplicatedBlocksWhenArchiving; - } - }