[net processing] Simplify sendcmpct processing

nCMPCTBLOCKVersion must always be 2 when processing.
This commit is contained in:
John Newbery 2021-01-02 15:17:53 +00:00
parent 42882fc8fc
commit 25edb2b7bd

View file

@ -2891,17 +2891,15 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
if (!State(pfrom.GetId())->fProvidesHeaderAndIDs) {
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
State(pfrom.GetId())->fWantsCmpctWitness = nCMPCTBLOCKVersion == 2;
State(pfrom.GetId())->fWantsCmpctWitness = true;
}
if (State(pfrom.GetId())->fWantsCmpctWitness == (nCMPCTBLOCKVersion == 2)) { // ignore later version announces
if (State(pfrom.GetId())->fWantsCmpctWitness) {
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
// 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;
}
if (!State(pfrom.GetId())->fSupportsDesiredCmpctVersion) {
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
}
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
return;
}