Skip to content

Commit ac82b99

Browse files
committed
[p2p] remove redundant NODE_WITNESS checks
nLocalServices defaults to NODE_WITNESS and these checks are obsolete
1 parent 6f8b198 commit ac82b99

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
861861
}
862862
m_connman.ForNode(nodeid, [this](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
863863
AssertLockHeld(::cs_main);
864-
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
864+
uint64_t nCMPCTBLOCKVersion = 2;
865865
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
866866
// As per BIP152, we only get 3 of our peers to announce
867867
// blocks using compact encodings.
@@ -1955,7 +1955,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
19551955

19561956
static uint32_t GetFetchFlags(const CNode& pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
19571957
uint32_t nFetchFlags = 0;
1958-
if ((pfrom.GetLocalServices() & NODE_WITNESS) && State(pfrom.GetId())->fHaveWitness) {
1958+
if (State(pfrom.GetId())->fHaveWitness) {
19591959
nFetchFlags |= MSG_WITNESS_FLAG;
19601960
}
19611961
return nFetchFlags;
@@ -2667,8 +2667,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
26672667
// they may wish to request compact blocks from us
26682668
bool fAnnounceUsingCMPCTBLOCK = false;
26692669
uint64_t nCMPCTBLOCKVersion = 2;
2670-
if (pfrom.GetLocalServices() & NODE_WITNESS)
2671-
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
2670+
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
26722671
nCMPCTBLOCKVersion = 1;
26732672
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
26742673
}
@@ -2686,7 +2685,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
26862685
bool fAnnounceUsingCMPCTBLOCK = false;
26872686
uint64_t nCMPCTBLOCKVersion = 0;
26882687
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
2689-
if (nCMPCTBLOCKVersion == 1 || ((pfrom.GetLocalServices() & NODE_WITNESS) && nCMPCTBLOCKVersion == 2)) {
2688+
if (nCMPCTBLOCKVersion == 1 || nCMPCTBLOCKVersion == 2) {
26902689
LOCK(cs_main);
26912690
// fProvidesHeaderAndIDs is used to "lock in" version of compact blocks we send (fWantsCmpctWitness)
26922691
if (!State(pfrom.GetId())->fProvidesHeaderAndIDs) {
@@ -2700,10 +2699,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
27002699
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
27012700
}
27022701
if (!State(pfrom.GetId())->fSupportsDesiredCmpctVersion) {
2703-
if (pfrom.GetLocalServices() & NODE_WITNESS)
2704-
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
2705-
else
2706-
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 1);
2702+
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = (nCMPCTBLOCKVersion == 2);
27072703
}
27082704
}
27092705
return;

0 commit comments

Comments
 (0)