Skip to content

Commit ca8549d

Browse files
committed
Always drop the least preferred HB peer when adding a new one.
When a BIP152 HB-mode peer is in the least preferred position and disconnects, they will not be by ForNode on the next loop. They will continue to sit in that position and prevent deactivating HB mode for peers that are still connected. There is no reason for them to stay in the list if already gone, so drop the first element unconditionally if there are too many. Fixes issue #9163.
1 parent 0c577f2 commit ca8549d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,11 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(const CNodeState* nodestate, CNode* pf
529529
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
530530
// As per BIP152, we only get 3 of our peers to announce
531531
// blocks using compact encodings.
532-
bool found = connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion](CNode* pnodeStop){
532+
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion](CNode* pnodeStop){
533533
connman.PushMessage(pnodeStop, NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion);
534534
return true;
535535
});
536-
if(found)
537-
lNodesAnnouncingHeaderAndIDs.pop_front();
536+
lNodesAnnouncingHeaderAndIDs.pop_front();
538537
}
539538
fAnnounceUsingCMPCTBLOCK = true;
540539
connman.PushMessage(pfrom, NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion);

0 commit comments

Comments
 (0)