aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2020-06-02 21:23:44 -0700
committerAmiti Uttarwar <amiti@uttarwar.org>2020-08-07 17:18:16 -0700
commit7f7b83deb2427599c129f4ff581d4d045461e459 (patch)
tree0612ff469f49f98f59a985d21c8847a97840cce8 /src/net.h
parent35839e963bf61d2da0d12f5b8cea74ac0e0fbd7b (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.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index f52fea72be..4834050122 100644
--- a/src/net.h
+++ b/src/net.h
@@ -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);