Skip to content

Commit 3b6bfbc

Browse files
committed
[net processing] Rename CNodeState compact block members
fPreferHeaderAndIDs -> m_requested_hb_cmpctblocks fProvidesHeaderAndIDs -> m_provides_cmpctblocks
1 parent d0e9774 commit 3b6bfbc

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/net_processing.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,10 @@ struct CNodeState {
367367
bool fPreferredDownload{false};
368368
//! Whether this peer wants invs or headers (when possible) for block announcements.
369369
bool fPreferHeaders{false};
370-
//! Whether this peer wants invs or cmpctblocks (when possible) for block announcements.
371-
bool fPreferHeaderAndIDs{false};
372-
/**
373-
* Whether this peer will send us cmpctblocks if we request them.
374-
*/
375-
bool fProvidesHeaderAndIDs{false};
370+
/** Whether this peer wants invs or cmpctblocks (when possible) for block announcements. */
371+
bool m_requested_hb_cmpctblocks{false};
372+
/** Whether this peer will send us cmpctblocks if we request them. */
373+
bool m_provides_cmpctblocks{false};
376374
//! Whether this peer can give us witnesses
377375
bool fHaveWitness{false};
378376

@@ -967,11 +965,11 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
967965
if (m_ignore_incoming_txs) return;
968966

969967
CNodeState* nodestate = State(nodeid);
970-
if (!nodestate || !nodestate->fProvidesHeaderAndIDs) {
968+
if (!nodestate || !nodestate->m_provides_cmpctblocks) {
971969
// Don't request compact blocks if the peer has not signalled support
972970
return;
973971
}
974-
if (nodestate->fProvidesHeaderAndIDs) {
972+
if (nodestate->m_provides_cmpctblocks) {
975973
int num_outbound_hb_peers = 0;
976974
for (std::list<NodeId>::iterator it = lNodesAnnouncingHeaderAndIDs.begin(); it != lNodesAnnouncingHeaderAndIDs.end(); it++) {
977975
if (*it == nodeid) {
@@ -1654,7 +1652,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
16541652
CNodeState &state = *State(pnode->GetId());
16551653
// If the peer has, or we announced to them the previous block already,
16561654
// but we don't think they have this one, go ahead and announce it
1657-
if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
1655+
if (state.m_requested_hb_cmpctblocks && !PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
16581656

16591657
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
16601658
hashBlock.ToString(), pnode->GetId());
@@ -1967,7 +1965,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
19671965
// they won't have a useful mempool to match against a compact block,
19681966
// and we don't feel like constructing the object for them, so
19691967
// instead we respond with the full, non-compact block.
1970-
bool fPeerWantsWitness = State(pfrom.GetId())->fProvidesHeaderAndIDs;
1968+
bool fPeerWantsWitness = State(pfrom.GetId())->m_provides_cmpctblocks;
19711969
int nSendFlags = fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
19721970
if (CanDirectFetch() && pindex->nHeight >= m_chainman.ActiveChain().Height() - MAX_CMPCTBLOCK_DEPTH) {
19731971
if ((fPeerWantsWitness || !fWitnessesPresentInARecentCompactBlock) && a_recent_compact_block && a_recent_compact_block->header.GetHash() == pindex->GetBlockHash()) {
@@ -2138,7 +2136,7 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, const CBlock& block, c
21382136
}
21392137
LOCK(cs_main);
21402138
const CNetMsgMaker msgMaker(pfrom.GetCommonVersion());
2141-
int nSendFlags = State(pfrom.GetId())->fProvidesHeaderAndIDs ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
2139+
int nSendFlags = State(pfrom.GetId())->m_provides_cmpctblocks ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
21422140
m_connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp));
21432141
}
21442142

@@ -2282,7 +2280,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
22822280
}
22832281
if (vGetData.size() > 0) {
22842282
if (!m_ignore_incoming_txs &&
2285-
nodestate->fProvidesHeaderAndIDs &&
2283+
nodestate->m_provides_cmpctblocks &&
22862284
vGetData.size() == 1 &&
22872285
mapBlocksInFlight.size() == 1 &&
22882286
pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
@@ -2879,8 +2877,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
28792877

28802878
LOCK(cs_main);
28812879
CNodeState* nodestate = State(pfrom.GetId());
2882-
nodestate->fProvidesHeaderAndIDs = true;
2883-
nodestate->fPreferHeaderAndIDs = sendcmpct_hb;
2880+
nodestate->m_provides_cmpctblocks = true;
2881+
nodestate->m_requested_hb_cmpctblocks = sendcmpct_hb;
28842882
// save whether peer selects us as BIP152 high-bandwidth peer
28852883
// (receiving sendcmpct(1) signals high-bandwidth, sendcmpct(0) low-bandwidth)
28862884
pfrom.m_bip152_highbandwidth_from = sendcmpct_hb;
@@ -3233,7 +3231,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32333231
// actually receive all the data read from disk over the network.
32343232
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep\n", pfrom.GetId(), MAX_BLOCKTXN_DEPTH);
32353233
CInv inv;
3236-
WITH_LOCK(cs_main, inv.type = State(pfrom.GetId())->fProvidesHeaderAndIDs ? MSG_WITNESS_BLOCK : MSG_BLOCK);
3234+
WITH_LOCK(cs_main, inv.type = State(pfrom.GetId())->m_provides_cmpctblocks ? MSG_WITNESS_BLOCK : MSG_BLOCK);
32373235
inv.hash = req.blockhash;
32383236
WITH_LOCK(peer->m_getdata_requests_mutex, peer->m_getdata_requests.push_back(inv));
32393237
// The message processing loop will go around again (without pausing) and we'll respond then
@@ -3609,7 +3607,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
36093607
return;
36103608
}
36113609

3612-
if (DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT) && !nodestate->fProvidesHeaderAndIDs) {
3610+
if (DeploymentActiveAt(*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT) && !nodestate->m_provides_cmpctblocks) {
36133611
// Don't bother trying to process compact blocks from v1 peers
36143612
// after segwit activates.
36153613
return;
@@ -4704,7 +4702,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47044702
LOCK(peer->m_block_inv_mutex);
47054703
std::vector<CBlock> vHeaders;
47064704
bool fRevertToInv = ((!state.fPreferHeaders &&
4707-
(!state.fPreferHeaderAndIDs || peer->m_blocks_for_headers_relay.size() > 1)) ||
4705+
(!state.m_requested_hb_cmpctblocks || peer->m_blocks_for_headers_relay.size() > 1)) ||
47084706
peer->m_blocks_for_headers_relay.size() > MAX_BLOCKS_TO_ANNOUNCE);
47094707
const CBlockIndex *pBestIndex = nullptr; // last header queued for delivery
47104708
ProcessBlockAvailability(pto->GetId()); // ensure pindexBestKnownBlock is up-to-date
@@ -4757,7 +4755,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47574755
}
47584756
}
47594757
if (!fRevertToInv && !vHeaders.empty()) {
4760-
if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) {
4758+
if (vHeaders.size() == 1 && state.m_requested_hb_cmpctblocks) {
47614759
// We only send up to 1 block as header-and-ids, as otherwise
47624760
// probably means we're doing an initial-ish-sync or they're slow
47634761
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,

0 commit comments

Comments
 (0)