aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-01-12 11:49:48 +0100
committerMarcoFalke <falke.marco@gmail.com>2017-01-12 11:50:14 +0100
commita65ced1a66575c652baf5084644b8647f531be8c (patch)
tree1ea16fee2ff178f810cf0a1a8fb872300b5cae8c /src/rpc
parent2456a835f0bc7796d9ff71f64837fa6790e2b7cc (diff)
parent918d1fb86b687693b4f248c14238676300872749 (diff)
downloadbitcoin-a65ced1a66575c652baf5084644b8647f531be8c.tar.xz
Merge #9518: Return height of last block pruned by pruneblockchain RPC
918d1fb Return height of last block pruned by pruneblockchain RPC (Russell Yanofsky)
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index caa92bef9d..f7cbd04664 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -820,7 +820,12 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
throw runtime_error(
"pruneblockchain\n"
"\nArguments:\n"
- "1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or to a unix timestamp to prune based on block time.\n");
+ "1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or to a unix timestamp to prune based on block time.\n"
+ "\nResult:\n"
+ "n (numeric) Height of the last block pruned.\n"
+ "\nExamples:\n"
+ + HelpExampleCli("pruneblockchain", "1000")
+ + HelpExampleRpc("pruneblockchain", "1000"));
if (!fPruneMode)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Cannot prune blocks because node is not in prune mode.");
@@ -847,11 +852,13 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Blockchain is too short for pruning.");
else if (height > chainHeight)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Blockchain is shorter than the attempted prune height.");
- else if (height > chainHeight - MIN_BLOCKS_TO_KEEP)
+ else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) {
LogPrint("rpc", "Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.");
+ height = chainHeight - MIN_BLOCKS_TO_KEEP;
+ }
PruneBlockFilesManual(height);
- return NullUniValue;
+ return uint64_t(height);
}
UniValue gettxoutsetinfo(const JSONRPCRequest& request)