Skip to content

Commit 3707f8c

Browse files
committed
p2p, rpc, refactor: remove CNodeStats::m_conn_type_string
1 parent 6cd242c commit 3707f8c

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:
@@ -630,7 +630,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
630630
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";
631631

632632
X(m_conn_type);
633-
stats.m_conn_type_string = ConnectionTypeAsString();
634633
}
635634
#undef X
636635

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 ConnectionType enum to a string value */
184+
std::string ConnectionTypeAsString(ConnectionType conn_type);
185+
183186
class NetEventsInterface;
184187
class CConnman
185188
{
@@ -726,7 +729,6 @@ class CNodeStats
726729
std::string m_network;
727730
uint32_t m_mapped_as;
728731
ConnectionType m_conn_type;
729-
std::string m_conn_type_string;
730732
};
731733

732734

@@ -1223,7 +1225,7 @@ class CNode
12231225
//! Sets the addrName only if it was not previously set
12241226
void MaybeSetAddrName(const std::string& addrNameIn);
12251227

1226-
std::string ConnectionTypeAsString() const;
1228+
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
12271229
};
12281230

12291231
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static RPCHelpMan getpeerinfo()
262262
recvPerMsgCmd.pushKV(i.first, i.second);
263263
}
264264
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
265-
obj.pushKV("connection_type", stats.m_conn_type_string);
265+
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));
266266

267267
ret.push_back(obj);
268268
}

0 commit comments

Comments
 (0)