Browse Source

Removed maxDuplicatedBlocksWhenArchiving setting as it's no longer needed.

block-archive
CalDescent 3 years ago
parent
commit
5656de79a2
  1. 2
      src/main/java/org/qortal/controller/repository/BlockArchiver.java
  2. 26
      src/main/java/org/qortal/repository/BlockArchiveWriter.java
  3. 2
      src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabaseArchiving.java
  4. 4
      src/main/java/org/qortal/repository/hsqldb/HSQLDBDatabasePruning.java
  5. 7
      src/main/java/org/qortal/settings/Settings.java

2
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());

26
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",

2
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()) {

4
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;
}

7
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;
}
}

Loading…
Cancel
Save