forked from Qortal/qortal
Removed maxDuplicatedBlocksWhenArchiving setting as it's no longer needed.
This commit is contained in:
parent
0657ca2969
commit
14acc4feb9
@ -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());
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -133,9 +133,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
|
||||
@ -592,8 +589,4 @@ public class Settings {
|
||||
return this.archiveInterval;
|
||||
}
|
||||
|
||||
public int getMaxDuplicatedBlocksWhenArchiving() {
|
||||
return this.maxDuplicatedBlocksWhenArchiving;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user