From 7b322df6296609570e368e5f326979279041c11f Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Tue, 28 Jul 2020 13:17:16 -0700 Subject: [PATCH] [net/refactor] Remove m_addr_fetch member var from CNode --- src/net.cpp | 5 ++--- src/net.h | 5 ++++- src/net_processing.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 047153972e..7509140640 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1648,7 +1648,7 @@ void CConnman::ThreadDNSAddressSeed() { LOCK(cs_vNodes); for (const CNode* pnode : vNodes) { - nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->m_addr_fetch && !pnode->IsManualConn() && !pnode->fInbound; + nRelevant += pnode->fSuccessfullyConnected && !pnode->IsFeelerConn() && !pnode->IsAddrFetchConn() && !pnode->IsManualConn() && !pnode->fInbound; } } if (nRelevant >= 2) { @@ -1758,7 +1758,7 @@ int CConnman::GetExtraOutboundCount() { LOCK(cs_vNodes); for (const CNode* pnode : vNodes) { - if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) { + if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->IsFeelerConn() && !pnode->fDisconnect && !pnode->IsAddrFetchConn() && pnode->fSuccessfullyConnected) { ++nOutbound; } } @@ -2739,7 +2739,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn : nTimeConnected(GetSystemTimeInSeconds()), addr(addrIn), addrBind(addrBindIn), - m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH), fInbound(conn_type_in == ConnectionType::INBOUND), nKeyedNetGroup(nKeyedNetGroupIn), // Don't relay addr messages to peers that we connect to as block-relay-only diff --git a/src/net.h b/src/net.h index f4fd33ec95..74f96d3a30 100644 --- a/src/net.h +++ b/src/net.h @@ -775,7 +775,6 @@ public: } // This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level bool m_legacyWhitelisted{false}; - bool m_addr_fetch{false}; bool fClient{false}; // set by version message bool m_limited_node{false}; //after BIP159, set by version message const bool fInbound; @@ -799,6 +798,10 @@ public: return m_conn_type == ConnectionType::FEELER; } + bool IsAddrFetchConn() const { + return m_conn_type == ConnectionType::ADDR_FETCH; + } + protected: mapMsgCmdSize mapSendBytesPerMsgCmd; mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 53d47b63b3..6a78924fef 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -473,7 +473,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS nPreferredDownload -= state->fPreferredDownload; // Whether this node should be marked as a preferred download node. - state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.m_addr_fetch && !node.fClient; + state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.IsAddrFetchConn() && !node.fClient; nPreferredDownload += state->fPreferredDownload; } @@ -829,7 +829,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) static bool IsOutboundDisconnectionCandidate(const CNode& node) { - return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.m_addr_fetch); + return !(node.fInbound || node.IsManualConn() || node.IsFeelerConn() || node.IsAddrFetchConn()); } void PeerLogicValidation::InitializeNode(CNode *pnode) { @@ -2581,7 +2581,7 @@ void ProcessMessage( connman.AddNewAddresses(vAddrOk, pfrom.addr, 2 * 60 * 60); if (vAddr.size() < 1000) pfrom.fGetAddr = false; - if (pfrom.m_addr_fetch) + if (pfrom.IsAddrFetchConn()) pfrom.fDisconnect = true; return; } @@ -4094,7 +4094,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto) // Start block sync if (pindexBestHeader == nullptr) pindexBestHeader = ::ChainActive().Tip(); - 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. + 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. if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { // Only actively request headers from a single peer, unless we're close to today. if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {