diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c6492b6349..50c776b81e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1042,7 +1042,7 @@ static bool IsLimitedPeer(const Peer& peer) static uint16_t GetHeadersLimit(const CNode& pfrom) { if (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS_VERSION) { - return MAX_HEADERS_RESULTS_NEW; + return MAX_HEADERS_RESULTS; } return MAX_HEADERS_RESULTS_OLD; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5927ca215b..16055175fb 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -996,7 +996,7 @@ static RPCHelpMan getblockheaders() "If verbose is true, each item is an Object with information about a single blockheader.\n", { {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, - {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS_NEW), ""}, + {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, {"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"}, }, { @@ -1054,11 +1054,11 @@ static RPCHelpMan getblockheaders() throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); } - int nCount = MAX_HEADERS_RESULTS_NEW; + int nCount = MAX_HEADERS_RESULTS; if (!request.params[1].isNull()) nCount = request.params[1].get_int(); - if (nCount <= 0 || nCount > (int)MAX_HEADERS_RESULTS_NEW) + if (nCount <= 0 || nCount > (int)MAX_HEADERS_RESULTS) throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range"); bool fVerbose = true; @@ -1134,7 +1134,7 @@ static RPCHelpMan getmerkleblocks() { {"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"}, {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, - {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS_NEW), ""}, + {"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""}, }, RPCResult{ RPCResult::Type::ARR, "", "", @@ -1163,11 +1163,11 @@ static RPCHelpMan getmerkleblocks() throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); } - int nCount = MAX_HEADERS_RESULTS_NEW; + int nCount = MAX_HEADERS_RESULTS; if (!request.params[2].isNull()) nCount = request.params[2].get_int(); - if (nCount <= 0 || nCount > (int)MAX_HEADERS_RESULTS_NEW) { + if (nCount <= 0 || nCount > (int)MAX_HEADERS_RESULTS) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range"); } diff --git a/src/validation.h b/src/validation.h index 37c661853f..e61d5b62a7 100644 --- a/src/validation.h +++ b/src/validation.h @@ -85,10 +85,9 @@ static const int MAX_SCRIPTCHECK_THREADS = 15; static const int DEFAULT_SCRIPTCHECK_THREADS = 0; /** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends * less than this number, we reached its tip. Changing this value is a protocol upgrade. */ +static const unsigned int MAX_HEADERS_RESULTS = 8000; +/** Superseded with new value in protocol version INCREASE_MAX_HEADERS_VERSION */ static const unsigned int MAX_HEADERS_RESULTS_OLD = 2000; -/** Introduced in protocol version INCREASE_MAX_HEADERS_VERSION */ -static const unsigned int MAX_HEADERS_RESULTS_NEW = 8000; - static const int64_t DEFAULT_MAX_TIP_AGE = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin