diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -867,7 +867,6 @@ // If true this node is being used as a short lived feeler. bool fFeeler{false}; bool m_addr_fetch{false}; - bool m_manual_connection{false}; // set by version message bool fClient{false}; // after BIP159, set by version message @@ -885,6 +884,8 @@ std::atomic_bool fPauseRecv{false}; std::atomic_bool fPauseSend{false}; + bool IsManualConn() const { return m_conn_type == ConnectionType::MANUAL; } + protected: mapMsgCmdSize mapSendBytesPerMsgCmd; mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv); diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -552,7 +552,7 @@ stats.cleanSubVer = cleanSubVer; } stats.fInbound = fInbound; - stats.m_manual_connection = m_manual_connection; + stats.m_manual_connection = IsManualConn(); stats.nStartingHeight = nStartingHeight; { LOCK(cs_vSend); @@ -1791,7 +1791,7 @@ nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->m_addr_fetch && - !pnode->m_manual_connection && !pnode->fInbound; + !pnode->IsManualConn() && !pnode->fInbound; } } if (nRelevant >= 2) { @@ -1915,9 +1915,9 @@ { LOCK(cs_vNodes); for (const CNode *pnode : vNodes) { - if (!pnode->fInbound && !pnode->m_manual_connection && - !pnode->fFeeler && !pnode->fDisconnect && - !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) { + if (!pnode->fInbound && !pnode->IsManualConn() && !pnode->fFeeler && + !pnode->fDisconnect && !pnode->m_addr_fetch && + pnode->fSuccessfullyConnected) { ++nOutbound; } } @@ -1995,7 +1995,8 @@ { LOCK(cs_vNodes); for (const CNode *pnode : vNodes) { - if (!pnode->fInbound && !pnode->m_manual_connection) { + if (!pnode->fInbound && + (pnode->m_conn_type != ConnectionType::MANUAL)) { // Netgroups for inbound and addnode peers are not excluded // because our goal here is to not use multiple of our // limited outbound slots on a single netgroup but inbound @@ -2989,7 +2990,6 @@ : nTimeConnected(GetSystemTimeInSeconds()), addr(addrIn), addrBind(addrBindIn), fFeeler(conn_type_in == ConnectionType::FEELER), m_addr_fetch(conn_type_in == ConnectionType::ADDR_FETCH), - m_manual_connection(conn_type_in == ConnectionType::MANUAL), fInbound(conn_type_in == ConnectionType::INBOUND), nKeyedNetGroup(nKeyedNetGroupIn), // Don't relay addr messages to peers that we connect to as diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -934,10 +934,8 @@ } } -// Returns true for outbound peers, excluding manual connections, feelers, and -// one-shots. static bool IsOutboundDisconnectionCandidate(const CNode &node) { - return !(node.fInbound || node.m_manual_connection || node.fFeeler || + return !(node.fInbound || node.IsManualConn() || node.fFeeler || node.m_addr_fetch); } @@ -951,7 +949,7 @@ mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, std::move(addrName), pnode->fInbound, - pnode->m_manual_connection)); + pnode->IsManualConn())); } if (!pnode->fInbound) { PushNodeVersion(config, *pnode, *connman, GetTime()); @@ -2539,7 +2537,7 @@ if (!pfrom.fInbound) { connman.SetServices(pfrom.addr, nServices); } - if (!pfrom.fInbound && !pfrom.fFeeler && !pfrom.m_manual_connection && + if (!pfrom.fInbound && !pfrom.fFeeler && !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices)) { LogPrint(BCLog::NET, "peer=%d does not offer the expected services " @@ -4201,7 +4199,7 @@ if (pnode.HasPermission(PF_NOBAN)) { LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode.addr.ToString()); - } else if (pnode.m_manual_connection) { + } else if (pnode.IsManualConn()) { LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode.addr.ToString()); } else if (pnode.addr.IsLocal()) {