Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 2,114 Lines • ▼ Show 20 Lines | while (!interruptNet) { | ||||
if (!interruptNet.sleep_for( | if (!interruptNet.sleep_for( | ||||
std::chrono::milliseconds(randsleep))) { | std::chrono::milliseconds(randsleep))) { | ||||
return; | return; | ||||
} | } | ||||
LogPrint(BCLog::NET, "Making feeler connection to %s\n", | LogPrint(BCLog::NET, "Making feeler connection to %s\n", | ||||
addrConnect.ToString()); | 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; | ConnectionType conn_type; | ||||
// 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) { | if (fFeeler) { | ||||
conn_type = ConnectionType::FEELER; | 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; | conn_type = ConnectionType::BLOCK_RELAY; | ||||
} else { | } else { | ||||
// GetTryNewOutboundPeer() is true | |||||
conn_type = ConnectionType::OUTBOUND; | conn_type = ConnectionType::OUTBOUND; | ||||
} | } | ||||
OpenNetworkConnection(addrConnect, | OpenNetworkConnection(addrConnect, | ||||
int(setConnected.size()) >= | int(setConnected.size()) >= | ||||
std::min(nMaxConnections - 1, 2), | std::min(nMaxConnections - 1, 2), | ||||
&grant, nullptr, conn_type); | &grant, nullptr, conn_type); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,018 Lines • Show Last 20 Lines |