Skip to content

Commit 0080fde

Browse files
laanwjcodablock
authored andcommitted
Merge bitcoin#9778: Add two hour buffer to manual pruning
91fb506 Add two hour buffer to manual pruning (Alex Morcos)
1 parent 86fd57b commit 0080fde

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/rpc/blockchain.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,8 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
954954
throw runtime_error(
955955
"pruneblockchain\n"
956956
"\nArguments:\n"
957-
"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"
957+
"1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
958+
" to prune blocks whose block time is at least 2 hours older than the provided timestamp.\n"
958959
"\nResult:\n"
959960
"n (numeric) Height of the last block pruned.\n"
960961
"\nExamples:\n"
@@ -973,7 +974,8 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
973974
// Height value more than a billion is too high to be a block height, and
974975
// too low to be a block time (corresponds to timestamp from Sep 2001).
975976
if (heightParam > 1000000000) {
976-
CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam);
977+
// Add a 2 hour buffer to include blocks which might have had old timestamps
978+
CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam - 7200);
977979
if (!pindex) {
978980
throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not find block with at least the specified timestamp.");
979981
}

0 commit comments

Comments
 (0)