Skip to content

Commit ad168ef

Browse files
committed
Merge #9778: Add two hour buffer to manual pruning
91fb506 Add two hour buffer to manual pruning (Alex Morcos)
2 parents 3c02b95 + 91fb506 commit ad168ef

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
@@ -820,7 +820,8 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
820820
throw runtime_error(
821821
"pruneblockchain\n"
822822
"\nArguments:\n"
823-
"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"
823+
"1. \"height\" (numeric, required) The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
824+
" to prune blocks whose block time is at least 2 hours older than the provided timestamp.\n"
824825
"\nResult:\n"
825826
"n (numeric) Height of the last block pruned.\n"
826827
"\nExamples:\n"
@@ -839,7 +840,8 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
839840
// Height value more than a billion is too high to be a block height, and
840841
// too low to be a block time (corresponds to timestamp from Sep 2001).
841842
if (heightParam > 1000000000) {
842-
CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam);
843+
// Add a 2 hour buffer to include blocks which might have had old timestamps
844+
CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam - 7200);
843845
if (!pindex) {
844846
throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not find block with at least the specified timestamp.");
845847
}

0 commit comments

Comments
 (0)