aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authormrbandrews <bandrewsny@gmail.com>2016-11-29 12:39:19 -0500
committermrbandrews <bandrewsny@gmail.com>2017-01-10 08:14:50 -0500
commit1fc4ec7bf224748d3d6271bffa23d121f015cbf3 (patch)
treea726cadbb46e5e41932be2f06477a145f16df911 /src/init.cpp
parent5754e0341b7c033d4caf99534aca47e9981bd7ed (diff)
downloadbitcoin-1fc4ec7bf224748d3d6271bffa23d121f015cbf3.tar.xz
Add pruneblockchain RPC to enable manual block file pruning.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 992ce8ebdc..9ac69b7d39 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -351,9 +351,9 @@ std::string HelpMessage(HelpMessageMode mode)
#ifndef WIN32
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), BITCOIN_PID_FILENAME));
#endif
- strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode is incompatible with -txindex and -rescan. "
+ strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. "
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
- "(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
+ "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >%u = automatically prune block files to stay under the specified target size in MiB)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
strUsage += HelpMessageOpt("-reindex-chainstate", _("Rebuild chain state from the currently indexed blocks"));
strUsage += HelpMessageOpt("-reindex", _("Rebuild chain state and block index from the blk*.dat files on disk"));
#ifndef WIN32
@@ -936,12 +936,16 @@ bool AppInitParameterInteraction()
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
- int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024;
- if (nSignedPruneTarget < 0) {
+ int64_t nPruneArg = GetArg("-prune", 0);
+ if (nPruneArg < 0) {
return InitError(_("Prune cannot be configured with a negative value."));
}
- nPruneTarget = (uint64_t) nSignedPruneTarget;
- if (nPruneTarget) {
+ nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024;
+ if (nPruneArg == 1) { // manual pruning: -prune=1
+ LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
+ nPruneTarget = std::numeric_limits<uint64_t>::max();
+ fPruneMode = true;
+ } else if (nPruneTarget) {
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
}