Skip to content

Commit 4972c21

Browse files
committed
[net/refactor] Clarify logic for selecting connections in ThreadOpenConnections
1 parent 60156f5 commit 4972c21

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/net.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,15 +1936,20 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
19361936
LogPrint(BCLog::NET, "Making feeler connection to %s\n", addrConnect.ToString());
19371937
}
19381938

1939-
// Open this connection as block-relay-only if we're already at our
1940-
// full-relay capacity, but not yet at our block-relay peer limit.
1941-
bool block_relay_only = nOutboundBlockRelay < m_max_outbound_block_relay && nOutboundFullRelay >= m_max_outbound_full_relay;
19421939
ConnectionType conn_type;
1943-
if(fFeeler) {
1940+
// Determine what type of connection to open. If fFeeler is not
1941+
// set, open OUTBOUND connections until we meet our full-relay
1942+
// capacity. Then open BLOCK_RELAY connections until we hit our
1943+
// block-relay peer limit. Otherwise, default to opening an
1944+
// OUTBOUND connection.
1945+
if (fFeeler) {
19441946
conn_type = ConnectionType::FEELER;
1945-
} else if (block_relay_only) {
1947+
} else if (nOutboundFullRelay < m_max_outbound_full_relay) {
1948+
conn_type = ConnectionType::OUTBOUND;
1949+
} else if (nOutboundBlockRelay < m_max_outbound_block_relay) {
19461950
conn_type = ConnectionType::BLOCK_RELAY;
19471951
} else {
1952+
// GetTryNewOutboundPeer() is true
19481953
conn_type = ConnectionType::OUTBOUND;
19491954
}
19501955

0 commit comments

Comments
 (0)