Skip to content

Commit

Permalink
merge bitcoin#25404: Use MAX_BLOCKS_TO_ANNOUNCE consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg authored and PastaPastaPasta committed Aug 9, 2024
1 parent ed871d2 commit 0574a7d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2813,15 +2813,15 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
LOCK(cs_main);
CNodeState *nodestate = State(pfrom.GetId());

// If this looks like it could be a block announcement (nCount <
// If this looks like it could be a block announcement (nCount <=
// MAX_BLOCKS_TO_ANNOUNCE), use special logic for handling headers that
// don't connect:
// - Send a getheaders message in response to try to connect the chain.
// - The peer can send up to MAX_UNCONNECTING_HEADERS in a row that
// don't connect before giving DoS points
// - Once a headers message is received that is valid and does connect,
// nUnconnectingHeaders gets reset back to 0.
if (!m_chainman.m_blockman.LookupBlockIndex(headers[0].hashPrevBlock) && nCount < MAX_BLOCKS_TO_ANNOUNCE) {
if (!m_chainman.m_blockman.LookupBlockIndex(headers[0].hashPrevBlock) && nCount <= MAX_BLOCKS_TO_ANNOUNCE) {
nodestate->nUnconnectingHeaders++;
std::string msg_type = (pfrom.nServices & NODE_HEADERS_COMPRESSED) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS;
m_connman.PushMessage(&pfrom, msgMaker.Make(msg_type, m_chainman.ActiveChain().GetLocator(m_chainman.m_best_header), uint256()));
Expand Down Expand Up @@ -5516,7 +5516,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
// Try sending block announcements via headers
//
if (pto->CanRelay()) {
// If we have less than MAX_BLOCKS_TO_ANNOUNCE in our
// If we have no more than MAX_BLOCKS_TO_ANNOUNCE in our
// list of block hashes we're relaying, and our peer wants
// headers announcements, then find the first header
// not yet known to our peer but would connect, and send.
Expand Down

0 comments on commit 0574a7d

Please sign in to comment.