@@ -113,9 +113,6 @@ static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
113113static constexpr auto BLOCK_STALLING_TIMEOUT_DEFAULT{2s};
114114/* * Maximum timeout for stalling block download. */
115115static 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 ;
119116/* * Maximum depth of blocks we're willing to serve as compact blocks to peers
120117 * when requested. For older blocks, a regular BLOCK response will be sent. */
121118static const int MAX_CMPCTBLOCK_DEPTH = 5 ;
@@ -2786,7 +2783,7 @@ bool PeerManagerImpl::CheckHeadersAreContinuous(const std::vector<CBlockHeader>&
27862783bool PeerManagerImpl::IsContinuationOfLowWorkHeadersSync (Peer& peer, CNode& pfrom, std::vector<CBlockHeader>& headers)
27872784{
27882785 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 );
27902787 // If it is a valid continuation, we should treat the existing getheaders request as responded to.
27912788 if (result.success ) peer.m_last_getheaders_timestamp = {};
27922789 if (result.request_more ) {
@@ -2880,7 +2877,7 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
28802877 // Only try to sync with this peer if their headers message was full;
28812878 // otherwise they don't have more headers after this so no point in
28822879 // trying to sync their too-little-work chain.
2883- if (headers.size () == MAX_HEADERS_RESULTS ) {
2880+ if (headers.size () == m_opts. max_headers_result ) {
28842881 // Note: we could advance to the last header in this set that is
28852882 // known to us, rather than starting at the first header (which we
28862883 // may already have); however this is unlikely to matter much since
@@ -3192,15 +3189,15 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
31923189 assert (pindexLast);
31933190
31943191 // 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) {
31963193 // Headers message had its maximum size; the peer may have more headers.
31973194 if (MaybeSendGetHeaders (pfrom, GetLocator (pindexLast), peer)) {
31983195 LogDebug (BCLog::NET, " more getheaders (%d) to end to peer=%d (startheight:%d)\n " ,
31993196 pindexLast->nHeight , pfrom.GetId (), peer.m_starting_height );
32003197 }
32013198 }
32023199
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 );
32043201
32053202 // Consider immediately downloading blocks.
32063203 HeadersDirectFetchBlocks (pfrom, peer, *pindexLast);
@@ -4518,7 +4515,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
45184515
45194516 // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
45204517 std::vector<CBlock> vHeaders;
4521- int nLimit = MAX_HEADERS_RESULTS ;
4518+ int nLimit = m_opts. max_headers_result ;
45224519 LogDebug (BCLog::NET, " getheaders %d to %s from peer=%d\n " , (pindex ? pindex->nHeight : -1 ), hashStop.IsNull () ? " end" : hashStop.ToString (), pfrom.GetId ());
45234520 for (; pindex; pindex = m_chainman.ActiveChain ().Next (pindex))
45244521 {
@@ -5002,7 +4999,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
50024999
50035000 // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks.
50045001 unsigned int nCount = ReadCompactSize (vRecv);
5005- if (nCount > MAX_HEADERS_RESULTS ) {
5002+ if (nCount > m_opts. max_headers_result ) {
50065003 Misbehaving (*peer, strprintf (" headers message size = %u" , nCount));
50075004 return ;
50085005 }
0 commit comments