trivial: rename MAX_HEADERS_RESULTS_NEW to MAX_HEADERS_RESULTS

We can reduce the diff by keeping the name `MAX_HEADERS_RESULTS` for
`MAX_HEADERS_RESULTS_NEW` as `MAX_HEADERS_RESULTS_OLD` is only
referenced once (in `GetHeadersLimit()`)
This commit is contained in:
Kittywhiskers Van Gogh 2024-08-30 09:24:07 +00:00 committed by pasta
parent bcf0320691
commit e23410ffdd
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
3 changed files with 9 additions and 10 deletions

View File

@ -1042,7 +1042,7 @@ static bool IsLimitedPeer(const Peer& peer)
static uint16_t GetHeadersLimit(const CNode& pfrom) static uint16_t GetHeadersLimit(const CNode& pfrom)
{ {
if (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS_VERSION) { if (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS_VERSION) {
return MAX_HEADERS_RESULTS_NEW; return MAX_HEADERS_RESULTS;
} }
return MAX_HEADERS_RESULTS_OLD; return MAX_HEADERS_RESULTS_OLD;
} }

View File

@ -996,7 +996,7 @@ static RPCHelpMan getblockheaders()
"If verbose is true, each item is an Object with information about a single blockheader.\n", "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"}, {"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"}, {"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"); 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()) if (!request.params[1].isNull())
nCount = request.params[1].get_int(); 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"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range");
bool fVerbose = true; bool fVerbose = true;
@ -1134,7 +1134,7 @@ static RPCHelpMan getmerkleblocks()
{ {
{"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"}, {"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"},
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"}, {"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{
RPCResult::Type::ARR, "", "", RPCResult::Type::ARR, "", "",
@ -1163,11 +1163,11 @@ static RPCHelpMan getmerkleblocks()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); 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()) if (!request.params[2].isNull())
nCount = request.params[2].get_int(); 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"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range");
} }

View File

@ -85,10 +85,9 @@ static const int MAX_SCRIPTCHECK_THREADS = 15;
static const int DEFAULT_SCRIPTCHECK_THREADS = 0; 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 /** 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. */ * 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; 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 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