Skip to content

Commit 7098509

Browse files
committed
p2p, rpc, refactor: remove CNodeStats::m_conn_type_string
1 parent cbfb5c9 commit 7098509

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/net.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ void CConnman::AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNet
507507
}
508508
}
509509

510-
std::string CNode::ConnectionTypeAsString() const
510+
std::string ConnectionTypeAsString(ConnectionType conn_type)
511511
{
512-
switch (m_conn_type) {
512+
switch (conn_type) {
513513
case ConnectionType::INBOUND:
514514
return "inbound";
515515
case ConnectionType::MANUAL:
@@ -628,7 +628,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
628628
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";
629629

630630
X(m_conn_type);
631-
stats.m_conn_type_string = ConnectionTypeAsString();
632631
}
633632
#undef X
634633

src/net.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ enum class ConnectionType {
180180
ADDR_FETCH,
181181
};
182182

183+
/** Convert enum ConnectionType to a string value */
184+
std::string ConnectionTypeAsString(ConnectionType conn_type);
185+
183186
class NetEventsInterface;
184187
class CConnman
185188
{
@@ -724,7 +727,6 @@ class CNodeStats
724727
Network m_network;
725728
uint32_t m_mapped_as;
726729
ConnectionType m_conn_type;
727-
std::string m_conn_type_string;
728730
};
729731

730732

@@ -1219,7 +1221,7 @@ class CNode
12191221
//! Sets the addrName only if it was not previously set
12201222
void MaybeSetAddrName(const std::string& addrNameIn);
12211223

1222-
std::string ConnectionTypeAsString() const;
1224+
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
12231225

12241226
/** Whether this peer is an inbound onion, e.g. connected via our Tor onion service. */
12251227
bool IsInboundOnion() const { return m_inbound_onion; }

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static RPCHelpMan getpeerinfo()
249249
recvPerMsgCmd.pushKV(i.first, i.second);
250250
}
251251
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
252-
obj.pushKV("connection_type", stats.m_conn_type_string);
252+
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
253253

254254
ret.push_back(obj);
255255
}

0 commit comments

Comments
 (0)