diff options
author | Gleb Naumenko <naumenko.gs@gmail.com> | 2019-12-24 13:18:44 -0500 |
---|---|---|
committer | Gleb Naumenko <naumenko.gs@gmail.com> | 2019-12-25 08:59:08 -0500 |
commit | ec45646de9e62b3d42c85716bfeb06d8f2b507dc (patch) | |
tree | 2d3717818d8ea1b9a53f9b53af2390f7aee9ac21 /src/net.cpp | |
parent | 8feb4e4b667361bf23344149c01594abebd56fdb (diff) |
Integrate ASN bucketing in Addrman and add tests
Instead of using /16 netgroups to bucket nodes in Addrman for connection
diversification, ASN, which better represents an actor in terms
of network-layer infrastructure, is used.
For testing, asmap.raw is used. It represents a minimal
asmap needed for testing purposes.
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp index 84692d2a79..004f1de583 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1758,7 +1758,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect) // 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()); + setConnected.insert(pnode->addr.GetGroup(addrman.m_asmap)); if (pnode->m_tx_relay == nullptr) { nOutboundBlockRelay++; } else if (!pnode->fFeeler) { @@ -1806,7 +1806,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect) } // Require outbound connections, other than feelers, to be to distinct network groups - if (!fFeeler && setConnected.count(addr.GetGroup())) { + if (!fFeeler && setConnected.count(addr.GetGroup(addrman.m_asmap))) { break; } @@ -2778,7 +2778,7 @@ CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const uint64_t CConnman::CalculateKeyedNetGroup(const CAddress& ad) const { - std::vector<unsigned char> vchNetGroup(ad.GetGroup()); + std::vector<unsigned char> vchNetGroup(ad.GetGroup(addrman.m_asmap)); return GetDeterministicRandomizer(RANDOMIZER_ID_NETGROUP).Write(vchNetGroup.data(), vchNetGroup.size()).Finalize(); } |