@@ -113,9 +113,6 @@ static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
113
113
static constexpr auto BLOCK_STALLING_TIMEOUT_DEFAULT{2s};
114
114
/* * Maximum timeout for stalling block download. */
115
115
static constexpr auto BLOCK_STALLING_TIMEOUT_MAX{64s};
116
- /* * Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
117
- * less than this number, we reached its tip. Changing this value is a protocol upgrade. */
118
- static const unsigned int MAX_HEADERS_RESULTS = 2000 ;
119
116
/* * Maximum depth of blocks we're willing to serve as compact blocks to peers
120
117
* when requested. For older blocks, a regular BLOCK response will be sent. */
121
118
static const int MAX_CMPCTBLOCK_DEPTH = 5 ;
@@ -2786,7 +2783,7 @@ bool PeerManagerImpl::CheckHeadersAreContinuous(const std::vector<CBlockHeader>&
2786
2783
bool PeerManagerImpl::IsContinuationOfLowWorkHeadersSync (Peer& peer, CNode& pfrom, std::vector<CBlockHeader>& headers)
2787
2784
{
2788
2785
if (peer.m_headers_sync ) {
2789
- auto result = peer.m_headers_sync ->ProcessNextHeaders (headers, headers.size () == MAX_HEADERS_RESULTS );
2786
+ auto result = peer.m_headers_sync ->ProcessNextHeaders (headers, headers.size () == m_opts. max_headers_result );
2790
2787
// If it is a valid continuation, we should treat the existing getheaders request as responded to.
2791
2788
if (result.success ) peer.m_last_getheaders_timestamp = {};
2792
2789
if (result.request_more ) {
@@ -2880,7 +2877,7 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
2880
2877
// Only try to sync with this peer if their headers message was full;
2881
2878
// otherwise they don't have more headers after this so no point in
2882
2879
// trying to sync their too-little-work chain.
2883
- if (headers.size () == MAX_HEADERS_RESULTS ) {
2880
+ if (headers.size () == m_opts. max_headers_result ) {
2884
2881
// Note: we could advance to the last header in this set that is
2885
2882
// known to us, rather than starting at the first header (which we
2886
2883
// may already have); however this is unlikely to matter much since
@@ -3192,15 +3189,15 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
3192
3189
assert (pindexLast);
3193
3190
3194
3191
// Consider fetching more headers if we are not using our headers-sync mechanism.
3195
- if (nCount == MAX_HEADERS_RESULTS && !have_headers_sync) {
3192
+ if (nCount == m_opts. max_headers_result && !have_headers_sync) {
3196
3193
// Headers message had its maximum size; the peer may have more headers.
3197
3194
if (MaybeSendGetHeaders (pfrom, GetLocator (pindexLast), peer)) {
3198
3195
LogDebug (BCLog::NET, " more getheaders (%d) to end to peer=%d (startheight:%d)\n " ,
3199
3196
pindexLast->nHeight , pfrom.GetId (), peer.m_starting_height );
3200
3197
}
3201
3198
}
3202
3199
3203
- UpdatePeerStateForReceivedHeaders (pfrom, peer, *pindexLast, received_new_header, nCount == MAX_HEADERS_RESULTS );
3200
+ UpdatePeerStateForReceivedHeaders (pfrom, peer, *pindexLast, received_new_header, nCount == m_opts. max_headers_result );
3204
3201
3205
3202
// Consider immediately downloading blocks.
3206
3203
HeadersDirectFetchBlocks (pfrom, peer, *pindexLast);
@@ -4518,7 +4515,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4518
4515
4519
4516
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
4520
4517
std::vector<CBlock> vHeaders;
4521
- int nLimit = MAX_HEADERS_RESULTS ;
4518
+ int nLimit = m_opts. max_headers_result ;
4522
4519
LogDebug (BCLog::NET, " getheaders %d to %s from peer=%d\n " , (pindex ? pindex->nHeight : -1 ), hashStop.IsNull () ? " end" : hashStop.ToString (), pfrom.GetId ());
4523
4520
for (; pindex; pindex = m_chainman.ActiveChain ().Next (pindex))
4524
4521
{
@@ -5002,7 +4999,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
5002
4999
5003
5000
// Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks.
5004
5001
unsigned int nCount = ReadCompactSize (vRecv);
5005
- if (nCount > MAX_HEADERS_RESULTS ) {
5002
+ if (nCount > m_opts. max_headers_result ) {
5006
5003
Misbehaving (*peer, strprintf (" headers message size = %u" , nCount));
5007
5004
return ;
5008
5005
}
0 commit comments