diff options
author | Alex Morcos <morcos@chaincode.com> | 2017-02-16 11:07:15 -0500 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2017-02-16 17:47:56 -0500 |
commit | 91fb506e0a156d5b4f2e9ca76ee8de0b591b2ee0 (patch) | |
tree | e7125dd6ab4eca8a5fe9ac7b3940320c14441f31 /src/rpc/blockchain.cpp | |
parent | afae75fd3dad48b7a5db72732141d421c6864b9b (diff) | |
download | bitcoin-91fb506e0a156d5b4f2e9ca76ee8de0b591b2ee0.tar.xz |
Add two hour buffer to manual pruning
Diffstat (limited to 'src/rpc/blockchain.cpp')
-rw-r--r-- | src/rpc/blockchain.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 368654bfa6..7b69c81ff9 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -820,7 +820,8 @@ 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 a unix timestamp\n" + " to prune blocks whose block time is at least 2 hours older than the provided timestamp.\n" "\nResult:\n" "n (numeric) Height of the last block pruned.\n" "\nExamples:\n" @@ -839,7 +840,8 @@ UniValue pruneblockchain(const JSONRPCRequest& request) // Height value more than a billion is too high to be a block height, and // too low to be a block time (corresponds to timestamp from Sep 2001). if (heightParam > 1000000000) { - CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam); + // Add a 2 hour buffer to include blocks which might have had old timestamps + CBlockIndex* pindex = chainActive.FindEarliestAtLeast(heightParam - 7200); if (!pindex) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not find block with at least the specified timestamp."); } |