aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-01-08 15:14:33 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-01-08 15:14:53 +0100
commit9158d6f34153dc937e109d0e7486e956a26f20aa (patch)
treeafa58ad48fe854ac6d9fb5947e9cd5b702b432c6 /src/net.h
parent1e078f17b5dc94fae329b38057512994532a32de (diff)
parentfaecb74562d012a336837d3b39572c235ad2eb9d (diff)
downloadbitcoin-9158d6f34153dc937e109d0e7486e956a26f20aa.tar.xz
Merge #20786: net: [refactor] Prefer integral types in CNodeStats
faecb74562d012a336837d3b39572c235ad2eb9d Expose integral m_conn_type in CNodeStats, remove m_conn_type_string (Jon Atack) Pull request description: Currently, strings are stored for what are actually integral (strong) enum types. This is fine, because the strings are only used as-is for the debug log and RPC. However, it complicates using them in the GUI. User facing strings in the GUI should be translated and only string literals can be picked up for translation, not runtime `std::string`s. Fix that by removing the `std::string` members and replace them by strong enum integral types. ACKs for top commit: jonatack: Code review ACK faecb74562d012a336837d3b39572c235ad2eb9d theStack: Code review ACK faecb74562d012a336837d3b39572c235ad2eb9d 🌲 Tree-SHA512: 24df2bd0645432060e393eb44b8abaf20fe296457d07a867b0e735c3e2e75af7b03fc6bfeca734ec33ab816a7c8e1f8591a5ec342f3afe3098a4e41f5c2cfebb
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/net.h b/src/net.h
index 6c167954df..0fe9b75790 100644
--- a/src/net.h
+++ b/src/net.h
@@ -174,6 +174,8 @@ enum class ConnectionType {
ADDR_FETCH,
};
+/** Convert ConnectionType enum to a string value */
+std::string ConnectionTypeAsString(ConnectionType conn_type);
void Discover();
uint16_t GetListenPort();
@@ -264,11 +266,10 @@ public:
// Network the peer connected through
Network m_network;
uint32_t m_mapped_as;
- std::string m_conn_type_string;
+ ConnectionType m_conn_type;
};
-
/** Transport protocol agnostic message container.
* Ideally it should only contain receive time, payload,
* command and size.
@@ -756,7 +757,7 @@ public:
//! 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); }
/** Whether this peer is an inbound onion, e.g. connected via our Tor onion service. */
bool IsInboundOnion() const { return m_inbound_onion; }