Skip to content

Commit 860402e

Browse files
committed
[net] Remove trivial GetConnectionType() getter
1 parent b5a85b3 commit 860402e

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/net.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ bool CConnman::AttemptToEvictConnection()
917917
.m_is_local = node->addr.IsLocal(),
918918
.m_network = node->ConnectedThroughNetwork(),
919919
.m_noban = node->HasPermission(NetPermissionFlags::NoBan),
920-
.m_conn_type = node->GetConnectionType(),
920+
.m_conn_type = node->m_conn_type,
921921
};
922922
vEvictionCandidates.push_back(candidate);
923923
}
@@ -1092,7 +1092,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
10921092

10931093
// Count existing connections
10941094
int existing_connections = WITH_LOCK(m_nodes_mutex,
1095-
return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->GetConnectionType() == conn_type; }););
1095+
return std::count_if(m_nodes.begin(), m_nodes.end(), [conn_type](CNode* node) { return node->m_conn_type == conn_type; }););
10961096

10971097
// Max connections of specified type already exist
10981098
if (max_connections != std::nullopt && existing_connections >= max_connections) return false;
@@ -1711,7 +1711,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17111711
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
17121712

17131713
// Make sure our persistent outbound slots belong to different netgroups.
1714-
switch (pnode->GetConnectionType()) {
1714+
switch (pnode->m_conn_type) {
17151715
// We currently don't take inbound connections into account. Since they are
17161716
// free to make, an attacker could make them to prevent us from connecting to
17171717
// certain peers.
@@ -2777,9 +2777,9 @@ CNode::CNode(NodeId idIn,
27772777
m_inbound_onion{inbound_onion},
27782778
m_prefer_evict{node_opts.prefer_evict},
27792779
nKeyedNetGroup{nKeyedNetGroupIn},
2780+
m_conn_type{conn_type_in},
27802781
id{idIn},
27812782
nLocalHostNonce{nLocalHostNonceIn},
2782-
m_conn_type{conn_type_in},
27832783
m_i2p_sam_session{std::move(node_opts.i2p_sam_session)}
27842784
{
27852785
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);

src/net.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,7 @@ class CNode
418418
std::atomic_bool fPauseRecv{false};
419419
std::atomic_bool fPauseSend{false};
420420

421-
const ConnectionType& GetConnectionType() const
422-
{
423-
return m_conn_type;
424-
}
421+
const ConnectionType m_conn_type;
425422

426423
/** Move all messages from the received queue to the processing queue. */
427424
void MarkReceivedMsgsForProcessing(unsigned int recv_flood_size)
@@ -622,7 +619,6 @@ class CNode
622619
private:
623620
const NodeId id;
624621
const uint64_t nLocalHostNonce;
625-
const ConnectionType m_conn_type;
626622
std::atomic<int> m_greatest_common_version{INIT_PROTO_VERSION};
627623

628624
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread

0 commit comments

Comments
 (0)