Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 1,886 Lines • ▼ Show 20 Lines | while (!interruptNet) { | ||||
if (!pnode->fInbound && !pnode->m_manual_connection) { | if (!pnode->fInbound && !pnode->m_manual_connection) { | ||||
// Netgroups for inbound and addnode peers are not excluded | // Netgroups for inbound and addnode peers are not excluded | ||||
// because our goal here is to not use multiple of our | // because our goal here is to not use multiple of our | ||||
// limited outbound slots on a single netgroup but inbound | // limited outbound slots on a single netgroup but inbound | ||||
// and addnode peers do not use our outbound slots. Inbound | // and addnode peers do not use our outbound slots. Inbound | ||||
// peers also have the added issue that they're attacker | // peers also have the added issue that they're attacker | ||||
// controlled and could be used to prevent us from | // controlled and could be used to prevent us from | ||||
// connecting to particular hosts if we used them here. | // connecting to particular hosts if we used them here. | ||||
setConnected.insert(pnode->addr.GetGroup()); | setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap)); | ||||
if (pnode->m_tx_relay == nullptr) { | if (pnode->m_tx_relay == nullptr) { | ||||
nOutboundBlockRelay++; | nOutboundBlockRelay++; | ||||
} else if (!pnode->fFeeler) { | } else if (!pnode->fFeeler) { | ||||
nOutboundFullRelay++; | nOutboundFullRelay++; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 34 Lines | while (!interruptNet) { | ||||
// SelectTriedCollision returns an invalid address if it is empty. | // SelectTriedCollision returns an invalid address if it is empty. | ||||
if (!fFeeler || !addr.IsValid()) { | if (!fFeeler || !addr.IsValid()) { | ||||
addr = addrman.Select(fFeeler); | addr = addrman.Select(fFeeler); | ||||
} | } | ||||
// Require outbound connections, other than feelers, to be to | // Require outbound connections, other than feelers, to be to | ||||
// distinct network groups | // distinct network groups | ||||
if (!fFeeler && setConnected.count(addr.GetGroup())) { | if (!fFeeler && | ||||
setConnected.count(addr.GetGroup(addrman.m_asmap))) { | |||||
break; | break; | ||||
} | } | ||||
// if we selected an invalid or local address, restart | // if we selected an invalid or local address, restart | ||||
if (!addr.IsValid() || IsLocal(addr)) { | if (!addr.IsValid() || IsLocal(addr)) { | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,035 Lines • ▼ Show 20 Lines | return now + int64_t(log1p(GetRand(1ULL << 48) * | ||||
0.5); | 0.5); | ||||
} | } | ||||
CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const { | CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const { | ||||
return CSipHasher(nSeed0, nSeed1).Write(id); | return CSipHasher(nSeed0, nSeed1).Write(id); | ||||
} | } | ||||
uint64_t CConnman::CalculateKeyedNetGroup(const CAddress &ad) const { | uint64_t CConnman::CalculateKeyedNetGroup(const CAddress &ad) const { | ||||
std::vector<uint8_t> vchNetGroup(ad.GetGroup()); | std::vector<uint8_t> vchNetGroup(ad.GetGroup(addrman.m_asmap)); | ||||
return GetDeterministicRandomizer(RANDOMIZER_ID_NETGROUP) | return GetDeterministicRandomizer(RANDOMIZER_ID_NETGROUP) | ||||
.Write(vchNetGroup.data(), vchNetGroup.size()) | .Write(vchNetGroup.data(), vchNetGroup.size()) | ||||
.Finalize(); | .Finalize(); | ||||
} | } | ||||
/** | /** | ||||
* This function convert MaxBlockSize from byte to | * This function convert MaxBlockSize from byte to | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |