mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-12 13:43:43 +01:00
Add pruneblockchain RPC to enable manual block file pruning.
This commit is contained in:
16
src/init.cpp
16
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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user