diff options
| author | Amiti Uttarwar <[email protected]> | 2020-05-20 14:16:24 -0700 |
|---|---|---|
| committer | Amiti Uttarwar <[email protected]> | 2020-08-07 17:18:16 -0700 |
| commit | 4972c21b671ff73f13a1b5053338b6abbdb471b5 (patch) | |
| tree | 7156bf8535c553f337bc2e8d8b2c2a9158624155 /src/net.cpp | |
| parent | [net/refactor] Remove fInbound flag from CNode (diff) | |
| download | discoin-4972c21b671ff73f13a1b5053338b6abbdb471b5.tar.xz discoin-4972c21b671ff73f13a1b5053338b6abbdb471b5.zip | |
[net/refactor] Clarify logic for selecting connections in ThreadOpenConnections
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/net.cpp b/src/net.cpp index 9d33bed2f..67db02d0a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1936,15 +1936,20 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect) LogPrint(BCLog::NET, "Making feeler connection to %s\n", addrConnect.ToString()); } - // Open this connection as block-relay-only if we're already at our - // full-relay capacity, but not yet at our block-relay peer limit. - bool block_relay_only = nOutboundBlockRelay < m_max_outbound_block_relay && nOutboundFullRelay >= m_max_outbound_full_relay; ConnectionType conn_type; - if(fFeeler) { + // Determine what type of connection to open. If fFeeler is not + // set, open OUTBOUND connections until we meet our full-relay + // capacity. Then open BLOCK_RELAY connections until we hit our + // block-relay peer limit. Otherwise, default to opening an + // OUTBOUND connection. + if (fFeeler) { conn_type = ConnectionType::FEELER; - } else if (block_relay_only) { + } else if (nOutboundFullRelay < m_max_outbound_full_relay) { + conn_type = ConnectionType::OUTBOUND; + } else if (nOutboundBlockRelay < m_max_outbound_block_relay) { conn_type = ConnectionType::BLOCK_RELAY; } else { + // GetTryNewOutboundPeer() is true conn_type = ConnectionType::OUTBOUND; } |