Skip to content

Commit

Permalink
merge bitcoin#20599: Tolerate sendheaders and sendcmpct messages befo…
Browse files Browse the repository at this point in the history
…re verack
  • Loading branch information
kwvg committed Jun 10, 2024
1 parent 799214b commit 2ce4818
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,34 @@ void PeerManagerImpl::ProcessMessage(
return;
}

if (msg_type == NetMsgType::SENDHEADERS) {
LOCK(cs_main);
State(pfrom.GetId())->fPreferHeaders = true;
return;
}

if (msg_type == NetMsgType::SENDHEADERS2) {
LOCK(cs_main);
State(pfrom.GetId())->fPreferHeadersCompressed = true;
return;
}

if (msg_type == NetMsgType::SENDCMPCT) {
bool fAnnounceUsingCMPCTBLOCK = false;
uint64_t nCMPCTBLOCKVersion = 1;
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
if (nCMPCTBLOCKVersion == 1) {
LOCK(cs_main);
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
// save whether peer selects us as BIP152 high-bandwidth peer
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
}
return;
}

// BIP155 defines feature negotiation of addrv2 and sendaddrv2, which must happen
// between VERSION and VERACK.
if (msg_type == NetMsgType::SENDADDRV2) {
Expand Down Expand Up @@ -3670,35 +3698,6 @@ void PeerManagerImpl::ProcessMessage(
return;
}

if (msg_type == NetMsgType::SENDHEADERS) {
LOCK(cs_main);
State(pfrom.GetId())->fPreferHeaders = true;
return;
}

if (msg_type == NetMsgType::SENDHEADERS2) {
LOCK(cs_main);
State(pfrom.GetId())->fPreferHeadersCompressed = true;
return;
}

if (msg_type == NetMsgType::SENDCMPCT) {
bool fAnnounceUsingCMPCTBLOCK = false;
uint64_t nCMPCTBLOCKVersion = 1;
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
if (nCMPCTBLOCKVersion == 1) {
LOCK(cs_main);
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
// save whether peer selects us as BIP152 high-bandwidth peer
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
}
return;
}


if (msg_type == NetMsgType::SENDDSQUEUE)
{
bool b;
Expand Down

0 comments on commit 2ce4818

Please sign in to comment.