Skip to content

Commit 2ce4818

Browse files
committed
merge bitcoin#20599: Tolerate sendheaders and sendcmpct messages before verack
1 parent 799214b commit 2ce4818

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

src/net_processing.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,6 +3532,34 @@ void PeerManagerImpl::ProcessMessage(
35323532
return;
35333533
}
35343534

3535+
if (msg_type == NetMsgType::SENDHEADERS) {
3536+
LOCK(cs_main);
3537+
State(pfrom.GetId())->fPreferHeaders = true;
3538+
return;
3539+
}
3540+
3541+
if (msg_type == NetMsgType::SENDHEADERS2) {
3542+
LOCK(cs_main);
3543+
State(pfrom.GetId())->fPreferHeadersCompressed = true;
3544+
return;
3545+
}
3546+
3547+
if (msg_type == NetMsgType::SENDCMPCT) {
3548+
bool fAnnounceUsingCMPCTBLOCK = false;
3549+
uint64_t nCMPCTBLOCKVersion = 1;
3550+
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
3551+
if (nCMPCTBLOCKVersion == 1) {
3552+
LOCK(cs_main);
3553+
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
3554+
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
3555+
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
3556+
// save whether peer selects us as BIP152 high-bandwidth peer
3557+
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
3558+
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
3559+
}
3560+
return;
3561+
}
3562+
35353563
// BIP155 defines feature negotiation of addrv2 and sendaddrv2, which must happen
35363564
// between VERSION and VERACK.
35373565
if (msg_type == NetMsgType::SENDADDRV2) {
@@ -3670,35 +3698,6 @@ void PeerManagerImpl::ProcessMessage(
36703698
return;
36713699
}
36723700

3673-
if (msg_type == NetMsgType::SENDHEADERS) {
3674-
LOCK(cs_main);
3675-
State(pfrom.GetId())->fPreferHeaders = true;
3676-
return;
3677-
}
3678-
3679-
if (msg_type == NetMsgType::SENDHEADERS2) {
3680-
LOCK(cs_main);
3681-
State(pfrom.GetId())->fPreferHeadersCompressed = true;
3682-
return;
3683-
}
3684-
3685-
if (msg_type == NetMsgType::SENDCMPCT) {
3686-
bool fAnnounceUsingCMPCTBLOCK = false;
3687-
uint64_t nCMPCTBLOCKVersion = 1;
3688-
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
3689-
if (nCMPCTBLOCKVersion == 1) {
3690-
LOCK(cs_main);
3691-
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
3692-
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
3693-
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
3694-
// save whether peer selects us as BIP152 high-bandwidth peer
3695-
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
3696-
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
3697-
}
3698-
return;
3699-
}
3700-
3701-
37023701
if (msg_type == NetMsgType::SENDDSQUEUE)
37033702
{
37043703
bool b;

0 commit comments

Comments
 (0)