Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,065 Lines • ▼ Show 20 Lines | if (heightParam < 0) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative block height."); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative block height."); | ||||
} | } | ||||
// Height value more than a billion is too high to be a block height, and | // 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). | // too low to be a block time (corresponds to timestamp from Sep 2001). | ||||
if (heightParam > 1000000000) { | if (heightParam > 1000000000) { | ||||
// Add a 2 hour buffer to include blocks which might have had old | // Add a 2 hour buffer to include blocks which might have had old | ||||
// timestamps | // timestamps | ||||
CBlockIndex *pindex = | CBlockIndex *pindex = ::ChainActive().FindEarliestAtLeast( | ||||
::ChainActive().FindEarliestAtLeast(heightParam - TIMESTAMP_WINDOW); | heightParam - TIMESTAMP_WINDOW, 0); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Could not find block with at least the specified timestamp."); | "Could not find block with at least the specified timestamp."); | ||||
} | } | ||||
heightParam = pindex->nHeight; | heightParam = pindex->nHeight; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,638 Lines • Show Last 20 Lines |