Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 1,987 Lines • ▼ Show 20 Lines | while (!interruptNet) { | ||||
// Choose an address to connect to based on most recently seen | // Choose an address to connect to based on most recently seen | ||||
// | // | ||||
CAddress addrConnect; | CAddress addrConnect; | ||||
// Only connect out to one peer per network group (/16 for IPv4). | // Only connect out to one peer per network group (/16 for IPv4). | ||||
int nOutboundFullRelay = 0; | int nOutboundFullRelay = 0; | ||||
int nOutboundBlockRelay = 0; | int nOutboundBlockRelay = 0; | ||||
std::set<std::vector<uint8_t>> setConnected; | std::set<std::vector<uint8_t>> setConnected; | ||||
{ | { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
for (const CNode *pnode : vNodes) { | for (const CNode *pnode : vNodes) { | ||||
if (!pnode->IsInboundConn() && | if (pnode->IsFullOutboundConn()) { | ||||
(pnode->m_conn_type != ConnectionType::MANUAL)) { | |||||
// Netgroups for inbound and addnode peers are not excluded | |||||
// because our goal here is to not use multiple of our | |||||
// limited outbound slots on a single netgroup but inbound | |||||
// and addnode peers do not use our outbound slots. Inbound | |||||
// peers also have the added issue that they're attacker | |||||
// controlled and could be used to prevent us from | |||||
// connecting to particular hosts if we used them here. | |||||
setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap)); | |||||
if (pnode->m_tx_relay == nullptr) { | |||||
nOutboundBlockRelay++; | |||||
} else if (pnode->m_conn_type == ConnectionType::OUTBOUND) { | |||||
nOutboundFullRelay++; | nOutboundFullRelay++; | ||||
} | } | ||||
if (pnode->IsBlockOnlyConn()) { | |||||
nOutboundBlockRelay++; | |||||
} | |||||
// Netgroups for inbound and manual peers are not excluded | |||||
// because our goal here is to not use multiple of our | |||||
// limited outbound slots on a single netgroup but inbound | |||||
// and manual peers do not use our outbound slots. Inbound | |||||
// peers also have the added issue that they could be attacker | |||||
// controlled and could be used to prevent us from connecting | |||||
// to particular hosts if we used them here. | |||||
switch (pnode->m_conn_type) { | |||||
case ConnectionType::INBOUND: | |||||
case ConnectionType::MANUAL: | |||||
break; | |||||
case ConnectionType::OUTBOUND: | |||||
case ConnectionType::BLOCK_RELAY: | |||||
case ConnectionType::ADDR_FETCH: | |||||
case ConnectionType::FEELER: | |||||
setConnected.insert( | |||||
pnode->addr.GetGroup(addrman.m_asmap)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
// Feeler Connections | // Feeler Connections | ||||
// | // | ||||
// Design goals: | // Design goals: | ||||
// * Increase the number of connectable addresses in the tried table. | // * Increase the number of connectable addresses in the tried table. | ||||
▲ Show 20 Lines • Show All 1,141 Lines • Show Last 20 Lines |