Skip to content

Commit e357c89

Browse files
committed
p2p, doc: Use MAX_BLOCKS_TO_ANNOUNCE consistently
It is an inclusive upper bound according to its definition.
1 parent 7f2c983 commit e357c89

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,15 +2208,15 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
22082208
LOCK(cs_main);
22092209
CNodeState *nodestate = State(pfrom.GetId());
22102210

2211-
// If this looks like it could be a block announcement (nCount <
2211+
// If this looks like it could be a block announcement (nCount <=
22122212
// MAX_BLOCKS_TO_ANNOUNCE), use special logic for handling headers that
22132213
// don't connect:
22142214
// - Send a getheaders message in response to try to connect the chain.
22152215
// - The peer can send up to MAX_UNCONNECTING_HEADERS in a row that
22162216
// don't connect before giving DoS points
22172217
// - Once a headers message is received that is valid and does connect,
22182218
// nUnconnectingHeaders gets reset back to 0.
2219-
if (!m_chainman.m_blockman.LookupBlockIndex(headers[0].hashPrevBlock) && nCount < MAX_BLOCKS_TO_ANNOUNCE) {
2219+
if (!m_chainman.m_blockman.LookupBlockIndex(headers[0].hashPrevBlock) && nCount <= MAX_BLOCKS_TO_ANNOUNCE) {
22202220
nodestate->nUnconnectingHeaders++;
22212221
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETHEADERS, m_chainman.ActiveChain().GetLocator(m_chainman.m_best_header), uint256()));
22222222
LogPrint(BCLog::NET, "received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d, nUnconnectingHeaders=%d)\n",
@@ -4772,7 +4772,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47724772
// Try sending block announcements via headers
47734773
//
47744774
{
4775-
// If we have less than MAX_BLOCKS_TO_ANNOUNCE in our
4775+
// If we have no more than MAX_BLOCKS_TO_ANNOUNCE in our
47764776
// list of block hashes we're relaying, and our peer wants
47774777
// headers announcements, then find the first header
47784778
// not yet known to our peer but would connect, and send.

0 commit comments

Comments
 (0)