Skip to content

Commit faecb74

Browse files
jonatackMarcoFalke
authored andcommitted
Expose integral m_conn_type in CNodeStats, remove m_conn_type_string
1 parent 4b8b71e commit faecb74

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/net.cpp

Lines changed: 3 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:
@@ -627,7 +627,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
627627
CService addrLocalUnlocked = GetAddrLocal();
628628
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";
629629

630-
stats.m_conn_type_string = ConnectionTypeAsString();
630+
X(m_conn_type);
631631
}
632632
#undef X
633633

src/net.h

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

183+
/** Convert ConnectionType enum to a string value */
184+
std::string ConnectionTypeAsString(ConnectionType conn_type);
183185
void Discover();
184186
void StartMapPort();
185187
void InterruptMapPort();
@@ -273,11 +275,10 @@ class CNodeStats
273275
// Network the peer connected through
274276
Network m_network;
275277
uint32_t m_mapped_as;
276-
std::string m_conn_type_string;
278+
ConnectionType m_conn_type;
277279
};
278280

279281

280-
281282
/** Transport protocol agnostic message container.
282283
* Ideally it should only contain receive time, payload,
283284
* command and size.
@@ -765,7 +766,7 @@ class CNode
765766
//! Sets the addrName only if it was not previously set
766767
void MaybeSetAddrName(const std::string& addrNameIn);
767768

768-
std::string ConnectionTypeAsString() const;
769+
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
769770

770771
/** Whether this peer is an inbound onion, e.g. connected via our Tor onion service. */
771772
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)