mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
change to _COMPRESSED or _UNCOMPRESSED
This commit is contained in:
parent
303bc7af99
commit
b137280df4
@ -1042,9 +1042,9 @@ static bool IsLimitedPeer(const Peer& peer)
|
||||
static uint16_t GetHeadersLimit(const CNode& pfrom, const std::string& msg_type)
|
||||
{
|
||||
if (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS2_VERSION && msg_type == NetMsgType::GETHEADERS2) {
|
||||
return MAX_HEADERS2_RESULTS;
|
||||
return MAX_HEADERS_COMPRESSED_RESULT;
|
||||
}
|
||||
return MAX_HEADERS_RESULTS;
|
||||
return MAX_HEADERS_UNCOMPRESSED_RESULTS;
|
||||
}
|
||||
|
||||
static void PushInv(Peer& peer, const CInv& inv)
|
||||
|
@ -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_HEADERS2_RESULTS), ""},
|
||||
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_COMPRESSED_RESULT), ""},
|
||||
{"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_HEADERS2_RESULTS;
|
||||
int nCount = MAX_HEADERS_COMPRESSED_RESULT;
|
||||
if (!request.params[1].isNull())
|
||||
nCount = request.params[1].get_int();
|
||||
|
||||
if (nCount <= 0 || nCount > (int)MAX_HEADERS2_RESULTS)
|
||||
if (nCount <= 0 || nCount > (int)MAX_HEADERS_COMPRESSED_RESULT)
|
||||
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_HEADERS2_RESULTS), ""},
|
||||
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_COMPRESSED_RESULT), ""},
|
||||
},
|
||||
RPCResult{
|
||||
RPCResult::Type::ARR, "", "",
|
||||
@ -1163,11 +1163,11 @@ static RPCHelpMan getmerkleblocks()
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||
}
|
||||
|
||||
int nCount = MAX_HEADERS2_RESULTS;
|
||||
int nCount = MAX_HEADERS_COMPRESSED_RESULT;
|
||||
if (!request.params[2].isNull())
|
||||
nCount = request.params[2].get_int();
|
||||
|
||||
if (nCount <= 0 || nCount > (int)MAX_HEADERS2_RESULTS) {
|
||||
if (nCount <= 0 || nCount > (int)MAX_HEADERS_COMPRESSED_RESULT) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range");
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ 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 = 2000;
|
||||
static const unsigned int MAX_HEADERS2_RESULTS = 8000;
|
||||
static const unsigned int MAX_HEADERS_UNCOMPRESSED_RESULTS = 2000;
|
||||
static const unsigned int MAX_HEADERS_COMPRESSED_RESULT = 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
|
||||
|
||||
|
@ -10,8 +10,8 @@ from test_framework.messages import (
|
||||
CInv,
|
||||
msg_ping,
|
||||
ser_string,
|
||||
MAX_HEADERS_RESULTS,
|
||||
MAX_HEADERS2_RESULTS,
|
||||
MAX_HEADERS_UNCOMPRESSED_RESULTS,
|
||||
MAX_HEADERS_COMPRESSED_RESULT,
|
||||
MAX_INV_SIZE,
|
||||
MAX_PROTOCOL_MESSAGE_LENGTH,
|
||||
msg_getdata,
|
||||
@ -154,11 +154,11 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||
self.test_oversized_msg(msg_getdata([CInv(MSG_TX, 1)] * size), size)
|
||||
|
||||
def test_oversized_headers_msg(self):
|
||||
size = MAX_HEADERS_RESULTS + 1
|
||||
size = MAX_HEADERS_UNCOMPRESSED_RESULTS + 1
|
||||
self.test_oversized_msg(msg_headers([CBlockHeader()] * size), size)
|
||||
|
||||
def test_oversized_headers2_msg(self):
|
||||
size = MAX_HEADERS2_RESULTS + 1
|
||||
size = MAX_HEADERS_COMPRESSED_RESULT + 1
|
||||
self.test_oversized_msg(msg_headers2([CBlockHeader()] * size), size)
|
||||
|
||||
def test_resource_exhaustion(self):
|
||||
|
@ -42,8 +42,8 @@ MAX_MONEY = 21000000 * COIN
|
||||
BIP125_SEQUENCE_NUMBER = 0xfffffffd # Sequence number that is BIP 125 opt-in and BIP 68-opt-out
|
||||
|
||||
MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024 # Maximum length of incoming protocol messages
|
||||
MAX_HEADERS_RESULTS = 2000 # Number of headers sent in one getheaders result
|
||||
MAX_HEADERS2_RESULTS = 8000 # Number of headers2 sent in one getheaders2 result
|
||||
MAX_HEADERS_UNCOMPRESSED_RESULTS = 2000 # Number of headers sent in one getheaders result
|
||||
MAX_HEADERS_COMPRESSED_RESULT = 8000 # Number of headers2 sent in one getheaders2 result
|
||||
MAX_INV_SIZE = 50000 # Maximum number of entries in an 'inv' protocol message
|
||||
|
||||
NODE_NETWORK = (1 << 0)
|
||||
|
@ -31,8 +31,8 @@ import threading
|
||||
from test_framework.messages import (
|
||||
CBlockHeader,
|
||||
CompressibleBlockHeader,
|
||||
MAX_HEADERS_RESULTS,
|
||||
MAX_HEADERS2_RESULTS,
|
||||
MAX_HEADERS_UNCOMPRESSED_RESULTS,
|
||||
MAX_HEADERS_COMPRESSED_RESULT,
|
||||
NODE_HEADERS_COMPRESSED,
|
||||
msg_addr,
|
||||
msg_addrv2,
|
||||
@ -734,7 +734,7 @@ class P2PDataStore(P2PInterface):
|
||||
break
|
||||
|
||||
# Truncate the list if there are too many headers
|
||||
max_results = MAX_HEADERS2_RESULTS if use_headers2 else MAX_HEADERS_RESULTS
|
||||
max_results = MAX_HEADERS_COMPRESSED_RESULT if use_headers2 else MAX_HEADERS_UNCOMPRESSED_RESULTS
|
||||
headers_list = headers_list[:-max_results - 1:-1]
|
||||
|
||||
return headers_list
|
||||
|
Loading…
Reference in New Issue
Block a user