[net processing] Remove fSupportsDesiredCmpctVersion

It is now completely redundant with fProvidesHeadersAndIDs.
This commit is contained in:
John Newbery 2021-01-02 15:24:17 +00:00
parent 25edb2b7bd
commit a45d53cab5

View file

@ -371,19 +371,12 @@ struct CNodeState {
bool fPreferHeaderAndIDs{false}; bool fPreferHeaderAndIDs{false};
/** /**
* Whether this peer will send us cmpctblocks if we request them. * Whether this peer will send us cmpctblocks if we request them.
* This is not used to gate request logic, as we really only care about fSupportsDesiredCmpctVersion,
* but is used as a flag to "lock in" the version of compact blocks (fWantsCmpctWitness) we send.
*/ */
bool fProvidesHeaderAndIDs{false}; bool fProvidesHeaderAndIDs{false};
//! Whether this peer can give us witnesses //! Whether this peer can give us witnesses
bool fHaveWitness{false}; bool fHaveWitness{false};
//! Whether this peer wants witnesses in cmpctblocks/blocktxns //! Whether this peer wants witnesses in cmpctblocks/blocktxns
bool fWantsCmpctWitness{false}; bool fWantsCmpctWitness{false};
/**
* If we've announced NODE_WITNESS to this peer: whether the peer sends witnesses in cmpctblocks/blocktxns,
* otherwise: whether this peer sends non-witnesses in cmpctblocks/blocktxns.
*/
bool fSupportsDesiredCmpctVersion{false};
/** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic. /** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic.
* *
@ -976,8 +969,8 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
if (m_ignore_incoming_txs) return; if (m_ignore_incoming_txs) return;
CNodeState* nodestate = State(nodeid); CNodeState* nodestate = State(nodeid);
if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) { if (!nodestate || !nodestate->fProvidesHeaderAndIDs) {
// Never ask from peers who can't provide witnesses. // Don't request compact blocks if the peer has not signalled support
return; return;
} }
if (nodestate->fProvidesHeaderAndIDs) { if (nodestate->fProvidesHeaderAndIDs) {
@ -2292,7 +2285,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
} }
if (vGetData.size() > 0) { if (vGetData.size() > 0) {
if (!m_ignore_incoming_txs && if (!m_ignore_incoming_txs &&
nodestate->fSupportsDesiredCmpctVersion && nodestate->fProvidesHeaderAndIDs &&
vGetData.size() == 1 && vGetData.size() == 1 &&
mapBlocksInFlight.size() == 1 && mapBlocksInFlight.size() == 1 &&
pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) { pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
@ -2899,7 +2892,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth) // (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK; pfrom.m_bip152_highbandwidth_from = fAnnounceUsingCMPCTBLOCK;
} }
State(pfrom.GetId())->fSupportsDesiredCmpctVersion = true;
return; return;
} }
@ -3625,7 +3617,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return; return;
} }
if (DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT) && !nodestate->fSupportsDesiredCmpctVersion) { if (DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT) && !nodestate->fProvidesHeaderAndIDs) {
// Don't bother trying to process compact blocks from v1 peers // Don't bother trying to process compact blocks from v1 peers
// after segwit activates. // after segwit activates.
return; return;