[net] Remove trivial GetConnectionType() getter

This commit is contained in:
dergoegge 2023-03-24 15:29:21 +01:00
parent b5a85b365a
commit 860402ef2e
2 changed files with 5 additions and 9 deletions

View file

@ -917,7 +917,7 @@ bool CConnman::AttemptToEvictConnection()
.m_is_local = node->addr.IsLocal(), .m_is_local = node->addr.IsLocal(),
.m_network = node->ConnectedThroughNetwork(), .m_network = node->ConnectedThroughNetwork(),
.m_noban = node->HasPermission(NetPermissionFlags::NoBan), .m_noban = node->HasPermission(NetPermissionFlags::NoBan),
.m_conn_type = node->GetConnectionType(), .m_conn_type = node->m_conn_type,
}; };
vEvictionCandidates.push_back(candidate); vEvictionCandidates.push_back(candidate);
} }
@ -1092,7 +1092,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
// Count existing connections // Count existing connections
int existing_connections = WITH_LOCK(m_nodes_mutex, int existing_connections = WITH_LOCK(m_nodes_mutex,
return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->GetConnectionType() == conn_type; });); return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->m_conn_type == conn_type; }););
// Max connections of specified type already exist // Max connections of specified type already exist
if (max_connections != std::nullopt && existing_connections >= max_connections) return false; if (max_connections != std::nullopt && existing_connections >= max_connections) return false;
@ -1711,7 +1711,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++; if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
// Make sure our persistent outbound slots belong to different netgroups. // Make sure our persistent outbound slots belong to different netgroups.
switch (pnode->GetConnectionType()) { switch (pnode->m_conn_type) {
// We currently don't take inbound connections into account. Since they are // We currently don't take inbound connections into account. Since they are
// free to make, an attacker could make them to prevent us from connecting to // free to make, an attacker could make them to prevent us from connecting to
// certain peers. // certain peers.
@ -2777,9 +2777,9 @@ CNode::CNode(NodeId idIn,
m_inbound_onion{inbound_onion}, m_inbound_onion{inbound_onion},
m_prefer_evict{node_opts.prefer_evict}, m_prefer_evict{node_opts.prefer_evict},
nKeyedNetGroup{nKeyedNetGroupIn}, nKeyedNetGroup{nKeyedNetGroupIn},
m_conn_type{conn_type_in},
id{idIn}, id{idIn},
nLocalHostNonce{nLocalHostNonceIn}, nLocalHostNonce{nLocalHostNonceIn},
m_conn_type{conn_type_in},
m_i2p_sam_session{std::move(node_opts.i2p_sam_session)} m_i2p_sam_session{std::move(node_opts.i2p_sam_session)}
{ {
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND); if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);

View file

@ -418,10 +418,7 @@ public:
std::atomic_bool fPauseRecv{false}; std::atomic_bool fPauseRecv{false};
std::atomic_bool fPauseSend{false}; std::atomic_bool fPauseSend{false};
const ConnectionType& GetConnectionType() const const ConnectionType m_conn_type;
{
return m_conn_type;
}
/** Move all messages from the received queue to the processing queue. */ /** Move all messages from the received queue to the processing queue. */
void MarkReceivedMsgsForProcessing(unsigned int recv_flood_size) void MarkReceivedMsgsForProcessing(unsigned int recv_flood_size)
@ -622,7 +619,6 @@ public:
private: private:
const NodeId id; const NodeId id;
const uint64_t nLocalHostNonce; const uint64_t nLocalHostNonce;
const ConnectionType m_conn_type;
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION}; std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread