From 2f2e13b6c2c8741ca9d825eaaef736ede484bc85 Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Mon, 20 Jul 2020 14:24:48 -0700 Subject: [net/refactor] Simplify multiple-connection checks Extract logic that check multiple connection types into interface functions & structure as switch statements. This makes it very clear what touch points are for accessing `m_conn_type` & using the switch statements enables the compiler to warn if a new connection type is introduced but not handled for these cases. --- src/net.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index 4834050122..444a1ceed2 100644 --- a/src/net.h +++ b/src/net.h @@ -789,6 +789,21 @@ public: std::atomic_bool fPauseRecv{false}; std::atomic_bool fPauseSend{false}; + bool IsOutboundOrBlockRelayConn() const { + switch(m_conn_type) { + case ConnectionType::OUTBOUND: + case ConnectionType::BLOCK_RELAY: + return true; + case ConnectionType::INBOUND: + case ConnectionType::MANUAL: + case ConnectionType::ADDR_FETCH: + case ConnectionType::FEELER: + return false; + } + + assert(false); + } + bool IsFullOutboundConn() const { return m_conn_type == ConnectionType::OUTBOUND; } -- cgit v1.2.3