forked from Qortal/qortal
"pruningEnabled" setting renamed to "topOnly"
Pruning is still a concept in the code, but since it relates to both archived and topOnly mode, it makes it cleaner to use "topOnly" to refer to the pruned db with no archive.
This commit is contained in:
parent
d25a77b633
commit
ea92ccb4c1
@ -465,7 +465,7 @@ public class AdminResource {
|
||||
|
||||
// Make sure we're not orphaning as far back as the archived blocks
|
||||
// FUTURE: we could support this by first importing earlier blocks from the archive
|
||||
if (Settings.getInstance().isPruningEnabled() ||
|
||||
if (Settings.getInstance().isTopOnly() ||
|
||||
Settings.getInstance().isArchiveEnabled()) {
|
||||
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
|
@ -507,12 +507,12 @@ public class BlockChain {
|
||||
chainTip = repository.getBlockRepository().getLastBlock();
|
||||
}
|
||||
|
||||
boolean pruningEnabled = Settings.getInstance().isPruningEnabled();
|
||||
boolean isTopOnly = Settings.getInstance().isTopOnly();
|
||||
boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
||||
boolean hasBlocks = (chainTip != null && chainTip.getHeight() > 1);
|
||||
|
||||
if (pruningEnabled && hasBlocks) {
|
||||
// Pruning is enabled and we have blocks, so it's possible that the genesis block has been pruned
|
||||
if (isTopOnly && hasBlocks) {
|
||||
// Top-only mode is enabled and we have blocks, so it's possible that the genesis block has been pruned
|
||||
// It's best not to validate it, and there's no real need to
|
||||
} else {
|
||||
// Check first block is Genesis Block
|
||||
@ -533,7 +533,7 @@ public class BlockChain {
|
||||
|
||||
// Set the number of blocks to validate based on the pruned state of the chain
|
||||
// If pruned, subtract an extra 10 to allow room for error
|
||||
int blocksToValidate = (pruningEnabled || archiveEnabled) ? Settings.getInstance().getPruneBlockLimit() - 10 : 1440;
|
||||
int blocksToValidate = (isTopOnly || archiveEnabled) ? Settings.getInstance().getPruneBlockLimit() - 10 : 1440;
|
||||
|
||||
int startHeight = Math.max(repository.getBlockRepository().getBlockchainHeight() - blocksToValidate, 1);
|
||||
BlockData detachedBlockData = repository.getBlockRepository().getDetachedBlockSignature(startHeight);
|
||||
|
@ -19,8 +19,8 @@ public class AtStatesPruner implements Runnable {
|
||||
Thread.currentThread().setName("AT States pruner");
|
||||
|
||||
boolean archiveMode = false;
|
||||
if (!Settings.getInstance().isPruningEnabled()) {
|
||||
// Pruning isn't enabled, but we might want to prune for the purposes of archiving
|
||||
if (!Settings.getInstance().isTopOnly()) {
|
||||
// Top-only mode isn't enabled, but we might want to prune for the purposes of archiving
|
||||
if (!Settings.getInstance().isArchiveEnabled()) {
|
||||
// No pruning or archiving, so we must not prune anything
|
||||
return;
|
||||
|
@ -19,8 +19,8 @@ public class BlockPruner implements Runnable {
|
||||
Thread.currentThread().setName("Block pruner");
|
||||
|
||||
boolean archiveMode = false;
|
||||
if (!Settings.getInstance().isPruningEnabled()) {
|
||||
// Pruning isn't enabled, but we might want to prune for the purposes of archiving
|
||||
if (!Settings.getInstance().isTopOnly()) {
|
||||
// Top-only mode isn't enabled, but we might want to prune for the purposes of archiving
|
||||
if (!Settings.getInstance().isArchiveEnabled()) {
|
||||
// No pruning or archiving, so we must not prune anything
|
||||
return;
|
||||
|
@ -16,7 +16,7 @@ public class PruneManager {
|
||||
|
||||
private static PruneManager instance;
|
||||
|
||||
private boolean pruningEnabled = Settings.getInstance().isPruningEnabled();
|
||||
private boolean isTopOnly = Settings.getInstance().isTopOnly();
|
||||
private int pruneBlockLimit = Settings.getInstance().getPruneBlockLimit();
|
||||
|
||||
private ExecutorService executorService;
|
||||
@ -35,7 +35,7 @@ public class PruneManager {
|
||||
public void start() {
|
||||
this.executorService = Executors.newCachedThreadPool(new DaemonThreadFactory());
|
||||
|
||||
if (Settings.getInstance().isPruningEnabled() &&
|
||||
if (Settings.getInstance().isTopOnly() &&
|
||||
!Settings.getInstance().isArchiveEnabled()) {
|
||||
// Top-only-sync
|
||||
this.startTopOnlySyncMode();
|
||||
@ -110,7 +110,7 @@ public class PruneManager {
|
||||
}
|
||||
|
||||
public boolean isBlockPruned(int height, Repository repository) throws DataException {
|
||||
if (!this.pruningEnabled) {
|
||||
if (!this.isTopOnly) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class Bootstrap {
|
||||
try {
|
||||
LOGGER.info("Checking repository state...");
|
||||
|
||||
final boolean pruningEnabled = Settings.getInstance().isPruningEnabled();
|
||||
final boolean pruningEnabled = Settings.getInstance().isTopOnly();
|
||||
final boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
||||
|
||||
// Avoid creating bootstraps from pruned nodes until officially supported
|
||||
@ -328,7 +328,7 @@ public class Bootstrap {
|
||||
}
|
||||
|
||||
private String getFilename() {
|
||||
boolean pruningEnabled = Settings.getInstance().isPruningEnabled();
|
||||
boolean pruningEnabled = Settings.getInstance().isTopOnly();
|
||||
boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
||||
|
||||
if (pruningEnabled) {
|
||||
|
@ -80,7 +80,7 @@ public abstract class RepositoryManager {
|
||||
|
||||
public static boolean prune(Repository repository) {
|
||||
// Bulk prune the database the first time we use pruning mode
|
||||
if (Settings.getInstance().isPruningEnabled() ||
|
||||
if (Settings.getInstance().isTopOnly() ||
|
||||
Settings.getInstance().isArchiveEnabled()) {
|
||||
if (RepositoryManager.canArchiveOrPrune()) {
|
||||
try {
|
||||
|
@ -115,7 +115,7 @@ public class Settings {
|
||||
|
||||
/** Whether we should prune old data to reduce database size
|
||||
* This prevents the node from being able to serve older blocks */
|
||||
private boolean pruningEnabled = false;
|
||||
private boolean topOnly = false;
|
||||
/** The amount of recent blocks we should keep when pruning */
|
||||
private int pruneBlockLimit = 1450;
|
||||
|
||||
@ -590,8 +590,8 @@ public class Settings {
|
||||
}
|
||||
|
||||
|
||||
public boolean isPruningEnabled() {
|
||||
return this.pruningEnabled;
|
||||
public boolean isTopOnly() {
|
||||
return this.topOnly;
|
||||
}
|
||||
|
||||
public int getPruneBlockLimit() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user