aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-01-02 15:35:24 +0000
committerJohn Newbery <john@johnnewbery.com>2022-05-15 16:13:31 -0400
commitd0e97741748aaaad2a89ca42e4898e7f01308b35 (patch)
treea8f2a9e3dc0d56b845b7ec4aa9b3c6c85dae7c94 /src
parent30c3a01874cf51d987a0ae2bb699bf50d82768ff (diff)
downloadbitcoin-d0e97741748aaaad2a89ca42e4898e7f01308b35.tar.xz
[net processing] Tidy up `sendcmpct` processing
- use better local variable names - drop unnecessary if statements
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index d50c1636fb..3a55de106b 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2870,23 +2870,20 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
}
if (msg_type == NetMsgType::SENDCMPCT) {
- bool fAnnounceUsingCMPCTBLOCK = false;
- uint64_t nCMPCTBLOCKVersion = 0;
- vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
+ bool sendcmpct_hb{false};
+ uint64_t sendcmpct_version{0};
+ vRecv >> sendcmpct_hb >> sendcmpct_version;
// Only support compact block relay with witnesses
- if (nCMPCTBLOCKVersion != CMPCTBLOCKS_VERSION) return;
+ if (sendcmpct_version != CMPCTBLOCKS_VERSION) return;
LOCK(cs_main);
- if (!State(pfrom.GetId())->fProvidesHeaderAndIDs) {
- State(pfrom.GetId())->fProvidesHeaderAndIDs = true;
- }
- if (State(pfrom.GetId())->fProvidesHeaderAndIDs) {
- 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;
- }
+ CNodeState* nodestate = State(pfrom.GetId());
+ nodestate->fProvidesHeaderAndIDs = true;
+ nodestate->fPreferHeaderAndIDs = sendcmpct_hb;
+ // 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 = sendcmpct_hb;
return;
}