Skip to content

Commit d0e9774

Browse files
committed
[net processing] Tidy up sendcmpct processing
- use better local variable names - drop unnecessary if statements
1 parent 30c3a01 commit d0e9774

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/net_processing.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,23 +2870,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
28702870
}
28712871

28722872
if (msg_type == NetMsgType::SENDCMPCT) {
2873-
bool fAnnounceUsingCMPCTBLOCK = false;
2874-
uint64_t nCMPCTBLOCKVersion = 0;
2875-
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
2873+
bool sendcmpct_hb{false};
2874+
uint64_t sendcmpct_version{0};
2875+
vRecv >> sendcmpct_hb >> sendcmpct_version;
28762876

28772877
// Only support compact block relay with witnesses
2878-
if (nCMPCTBLOCKVersion != CMPCTBLOCKS_VERSION) return;
2878+
if (sendcmpct_version != CMPCTBLOCKS_VERSION) return;
28792879

28802880
LOCK(cs_main);
2881-
if (!State(pfrom.GetId())->fProvidesHeaderAndIDs) {
2882-
State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
2883-
}
2884-
if (State(pfrom.GetId())->fProvidesHeaderAndIDs) {
2885-
State(pfrom.GetId())->fPreferHeaderAndIDs = fAnnounceUsingCMPCTBLOCK;
2886-
// save whether peer selects us as BIP152 high-bandwidth peer
2887-
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
2888-
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
2889-
}
2881+
CNodeState* nodestate = State(pfrom.GetId());
2882+
nodestate->fProvidesHeaderAndIDs = true;
2883+
nodestate->fPreferHeaderAndIDs = sendcmpct_hb;
2884+
// save whether peer selects us as BIP152 high-bandwidth peer
2885+
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
2886+
pfrom.m_bip152_highbandwidth_from = sendcmpct_hb;
28902887
return;
28912888
}
28922889

0 commit comments

Comments
 (0)