Skip to content

Commit

Permalink
p2p, rpc, refactor: remove CNodeStats::m_conn_type_string
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Dec 26, 2020
1 parent 6cd242c commit 3707f8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ void CConnman::AddWhitelistPermissionFlags(NetPermissionFlags& flags, const CNet
}
}

std::string CNode::ConnectionTypeAsString() const
std::string ConnectionTypeAsString(ConnectionType conn_type)
{
switch (m_conn_type) {
switch (conn_type) {
case ConnectionType::INBOUND:
return "inbound";
case ConnectionType::MANUAL:
Expand Down Expand Up @@ -630,7 +630,6 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : "";

X(m_conn_type);
stats.m_conn_type_string = ConnectionTypeAsString();
}
#undef X

Expand Down
6 changes: 4 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ enum class ConnectionType {
ADDR_FETCH,
};

/** Convert ConnectionType enum to a string value */
std::string ConnectionTypeAsString(ConnectionType conn_type);

class NetEventsInterface;
class CConnman
{
Expand Down Expand Up @@ -726,7 +729,6 @@ class CNodeStats
std::string m_network;
uint32_t m_mapped_as;
ConnectionType m_conn_type;
std::string m_conn_type_string;
};


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

std::string ConnectionTypeAsString() const;
std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
};

/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static RPCHelpMan getpeerinfo()
recvPerMsgCmd.pushKV(i.first, i.second);
}
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
obj.pushKV("connection_type", stats.m_conn_type_string);
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));

ret.push_back(obj);
}
Expand Down

0 comments on commit 3707f8c

Please sign in to comment.