diff options
author | Patrick Strateman <patrick.strateman@gmail.com> | 2015-08-25 17:06:15 -0700 |
---|---|---|
committer | Patrick Strateman <patrick.strateman@gmail.com> | 2015-08-30 22:09:14 -0700 |
commit | 027de94e1fba5484aed2393afd89edbaaffdb0eb (patch) | |
tree | f6feda479eed58f628c375b1834101b7a805f895 /src | |
parent | 000c18aaceeebdcaf65508fcdc3d00397971dcae (diff) |
Use network group instead of CNetAddr in final pass to select node to disconnect
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/net.cpp b/src/net.cpp index d266b2f21f..9264d68656 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -898,29 +898,29 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) { if (vEvictionCandidates.empty()) return false; - // Identify CNetAddr with the most connections - CNetAddr naMostConnections; + // Identify the network group with the most connections + std::vector<unsigned char> naMostConnections; unsigned int nMostConnections = 0; - std::map<CNetAddr, std::vector<CNodeRef> > mapAddrCounts; + std::map<std::vector<unsigned char>, std::vector<CNodeRef> > mapAddrCounts; BOOST_FOREACH(const CNodeRef &node, vEvictionCandidates) { - mapAddrCounts[node->addr].push_back(node); + mapAddrCounts[node->addr.GetGroup()].push_back(node); - if (mapAddrCounts[node->addr].size() > nMostConnections) { - nMostConnections = mapAddrCounts[node->addr].size(); - naMostConnections = node->addr; + if (mapAddrCounts[node->addr.GetGroup()].size() > nMostConnections) { + nMostConnections = mapAddrCounts[node->addr.GetGroup()].size(); + naMostConnections = node->addr.GetGroup(); } } - // Reduce to the CNetAddr with the most connections + // Reduce to the network group with the most connections vEvictionCandidates = mapAddrCounts[naMostConnections]; - // Do not disconnect peers who have only 1 evictable connection + // Do not disconnect peers if there is only 1 connection from their network group if (vEvictionCandidates.size() <= 1) // unless we prefer the new connection (for whitelisted peers) if (!fPreferNewConnection) return false; - // Disconnect the most recent connection from the CNetAddr with the most connections + // Disconnect the most recent connection from the network group with the most connections std::sort(vEvictionCandidates.begin(), vEvictionCandidates.end(), ReverseCompareNodeTimeConnected); vEvictionCandidates[0]->fDisconnect = true; |