Skip to content

Commit 7b322df

Browse files
committed
[net/refactor] Remove m_addr_fetch member var from CNode
1 parent 1492342 commit 7b322df

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/net.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ void CConnman::ThreadDNSAddressSeed()
16481648
{
16491649
LOCK(cs_vNodes);
16501650
for (const CNode* pnode : vNodes) {
1651-
nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound;
1651+
nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->IsAddrFetchConn() && !pnode->IsManualConn() && !pnode->fInbound;
16521652
}
16531653
}
16541654
if (nRelevant >= 2) {
@@ -1758,7 +1758,7 @@ int CConnman::GetExtraOutboundCount()
17581758
{
17591759
LOCK(cs_vNodes);
17601760
for (const CNode* pnode : vNodes) {
1761-
if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
1761+
if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->IsAddrFetchConn() && pnode->fSuccessfullyConnected) {
17621762
++nOutbound;
17631763
}
17641764
}
@@ -2739,7 +2739,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
27392739
: nTimeConnected(GetSystemTimeInSeconds()),
27402740
addr(addrIn),
27412741
addrBind(addrBindIn),
2742-
m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH),
27432742
fInbound(conn_type_in == ConnectionType::INBOUND),
27442743
nKeyedNetGroup(nKeyedNetGroupIn),
27452744
// Don't relay addr messages to peers that we connect to as block-relay-only

src/net.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,6 @@ class CNode
775775
}
776776
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
777777
bool m_legacyWhitelisted{false};
778-
bool m_addr_fetch{false};
779778
bool fClient{false}; // set by version message
780779
bool m_limited_node{false}; //after BIP159, set by version message
781780
const bool fInbound;
@@ -799,6 +798,10 @@ class CNode
799798
return m_conn_type == ConnectionType::FEELER;
800799
}
801800

801+
bool IsAddrFetchConn() const {
802+
return m_conn_type == ConnectionType::ADDR_FETCH;
803+
}
804+
802805
protected:
803806
mapMsgCmdSize mapSendBytesPerMsgCmd;
804807
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);

src/net_processing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS
473473
nPreferredDownload -= state->fPreferredDownload;
474474

475475
// Whether this node should be marked as a preferred download node.
476-
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.m_addr_fetch && !node.fClient;
476+
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.IsAddrFetchConn() && !node.fClient;
477477

478478
nPreferredDownload += state->fPreferredDownload;
479479
}
@@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
829829

830830
static bool IsOutboundDisconnectionCandidate(const CNode& node)
831831
{
832-
return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.m_addr_fetch);
832+
return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.IsAddrFetchConn());
833833
}
834834

835835
void PeerLogicValidation::InitializeNode(CNode *pnode) {
@@ -2581,7 +2581,7 @@ void ProcessMessage(
25812581
connman.AddNewAddresses(vAddrOk, pfrom.addr, 2 * 60 * 60);
25822582
if (vAddr.size() < 1000)
25832583
pfrom.fGetAddr = false;
2584-
if (pfrom.m_addr_fetch)
2584+
if (pfrom.IsAddrFetchConn())
25852585
pfrom.fDisconnect = true;
25862586
return;
25872587
}
@@ -4094,7 +4094,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
40944094
// Start block sync
40954095
if (pindexBestHeader == nullptr)
40964096
pindexBestHeader = ::ChainActive().Tip();
4097-
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->m_addr_fetch); // Download if this is a nice peer, or we have no nice peers and this one might do.
4097+
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->IsAddrFetchConn()); // Download if this is a nice peer, or we have no nice peers and this one might do.
40984098
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
40994099
// Only actively request headers from a single peer, unless we're close to today.
41004100
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {

0 commit comments

Comments
 (0)