diff options
author | Amiti Uttarwar <amiti@uttarwar.org> | 2020-06-02 21:23:44 -0700 |
---|---|---|
committer | Amiti Uttarwar <amiti@uttarwar.org> | 2020-08-07 17:18:16 -0700 |
commit | 7f7b83deb2427599c129f4ff581d4d045461e459 (patch) | |
tree | 0612ff469f49f98f59a985d21c8847a97840cce8 /src/net.h | |
parent | 35839e963bf61d2da0d12f5b8cea74ac0e0fbd7b (diff) |
[net/refactor] Rework ThreadOpenConnections logic
Make the connection counts explicit and extract into interface functions around
m_conn_type. Using explicit counting and switch statements where possible
should help prevent counting bugs in the future.
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -789,10 +789,18 @@ public: std::atomic_bool fPauseRecv{false}; std::atomic_bool fPauseSend{false}; + bool IsFullOutboundConn() const { + return m_conn_type == ConnectionType::OUTBOUND; + } + bool IsManualConn() const { return m_conn_type == ConnectionType::MANUAL; } + bool IsBlockOnlyConn() const { + return m_conn_type == ConnectionType::BLOCK_RELAY; + } + bool IsFeelerConn() const { return m_conn_type == ConnectionType::FEELER; } @@ -805,6 +813,21 @@ public: return m_conn_type == ConnectionType::INBOUND; } + bool ExpectServicesFromConn() const { + switch(m_conn_type) { + case ConnectionType::INBOUND: + case ConnectionType::MANUAL: + case ConnectionType::FEELER: + return false; + case ConnectionType::OUTBOUND: + case ConnectionType::BLOCK_RELAY: + case ConnectionType::ADDR_FETCH: + return true; + } + + assert(false); + } + protected: mapMsgCmdSize mapSendBytesPerMsgCmd; mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv); |