0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

[net processing] Tidy up sendcmpct processing

- use better local variable names
- drop unnecessary if statements
This commit is contained in:
John Newbery 2021-01-02 15:35:24 +00:00
parent 30c3a01874
commit d0e9774174

View file

@ -2870,23 +2870,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
} }
if (msg_type == NetMsgType::SENDCMPCT) { if (msg_type == NetMsgType::SENDCMPCT) {
bool fAnnounceUsingCMPCTBLOCK = false; bool sendcmpct_hb{false};
uint64_t nCMPCTBLOCKVersion = 0; uint64_t sendcmpct_version{0};
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion; vRecv >> sendcmpct_hb >> sendcmpct_version;
// Only support compact block relay with witnesses // Only support compact block relay with witnesses
if (nCMPCTBLOCKVersion != CMPCTBLOCKS_VERSION) return; if (sendcmpct_version != CMPCTBLOCKS_VERSION) return;
LOCK(cs_main); LOCK(cs_main);
if (!State(pfrom.GetId())->fProvidesHeaderAndIDs) { CNodeState* nodestate = State(pfrom.GetId());
State(pfrom.GetId())->fProvidesHeaderAndIDs = true; nodestate->fProvidesHeaderAndIDs = true;
} nodestate->fPreferHeaderAndIDs = sendcmpct_hb;
if (State(pfrom.GetId())->fProvidesHeaderAndIDs) { // save whether peer selects us as BIP152 high-bandwidth peer
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK; // (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
// save whether peer selects us as BIP152 high-bandwidth peer pfrom.m_bip152_highbandwidth_from = sendcmpct_hb;
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
}
return; return;
} }