aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2023-08-31 13:40:37 -0700
committerMartin Zumsande <mzumsande@gmail.com>2023-10-03 13:52:46 -0400
commitc25e0e05550426f29d79571368d90f63fb472b02 (patch)
treed2b0422ee6016c7580b88d2d316b0dbcf63e2433 /src/net.h
parent97f756b12c8d8a9d3b621f296725dd7bf36bc8a9 (diff)
net, refactor: move calculations for connection type limits into connman
Currently the logic is fragmented between init and connman. Encapsulating this logic within connman allows for less mental overhead and easier reuse in tests. Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/net.h b/src/net.h
index 2f7b832fba..46ab8dad33 100644
--- a/src/net.h
+++ b/src/net.h
@@ -1058,10 +1058,6 @@ public:
{
ServiceFlags nLocalServices = NODE_NONE;
int nMaxConnections = 0;
- int m_max_outbound_full_relay = 0;
- int m_max_outbound_block_relay = 0;
- int nMaxAddnode = 0;
- int nMaxFeeler = 0;
CClientUIInterface* uiInterface = nullptr;
NetEventsInterface* m_msgproc = nullptr;
BanMan* m_banman = nullptr;
@@ -1089,12 +1085,10 @@ public:
nLocalServices = connOptions.nLocalServices;
nMaxConnections = connOptions.nMaxConnections;
- m_max_outbound_full_relay = std::min(connOptions.m_max_outbound_full_relay, connOptions.nMaxConnections);
- m_max_outbound_block_relay = connOptions.m_max_outbound_block_relay;
- m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing;
- nMaxAddnode = connOptions.nMaxAddnode;
- nMaxFeeler = connOptions.nMaxFeeler;
+ m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, nMaxConnections);
+ m_max_outbound_block_relay = std::min(MAX_BLOCK_RELAY_ONLY_CONNECTIONS, nMaxConnections - m_max_outbound_full_relay);
m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler;
+ m_use_addrman_outgoing = connOptions.m_use_addrman_outgoing;
m_client_interface = connOptions.uiInterface;
m_banman = connOptions.m_banman;
m_msgproc = connOptions.m_msgproc;
@@ -1488,8 +1482,8 @@ private:
// We do not relay tx or addr messages with these peers
int m_max_outbound_block_relay;
- int nMaxAddnode;
- int nMaxFeeler;
+ int nMaxAddnode{MAX_ADDNODE_CONNECTIONS};
+ int nMaxFeeler{MAX_FEELER_CONNECTIONS};
int m_max_outbound;
bool m_use_addrman_outgoing;
CClientUIInterface* m_client_interface;