@@ -898,29 +898,29 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
898
898
899
899
if (vEvictionCandidates.empty ()) return false ;
900
900
901
- // Identify CNetAddr with the most connections
902
- CNetAddr naMostConnections;
901
+ // Identify the network group with the most connections
902
+ std::vector< unsigned char > naMostConnections;
903
903
unsigned int nMostConnections = 0 ;
904
- std::map<CNetAddr , std::vector<CNodeRef> > mapAddrCounts;
904
+ std::map<std::vector< unsigned char > , std::vector<CNodeRef> > mapAddrCounts;
905
905
BOOST_FOREACH (const CNodeRef &node, vEvictionCandidates) {
906
- mapAddrCounts[node->addr ].push_back (node);
906
+ mapAddrCounts[node->addr . GetGroup () ].push_back (node);
907
907
908
- if (mapAddrCounts[node->addr ].size () > nMostConnections) {
909
- nMostConnections = mapAddrCounts[node->addr ].size ();
910
- naMostConnections = node->addr ;
908
+ if (mapAddrCounts[node->addr . GetGroup () ].size () > nMostConnections) {
909
+ nMostConnections = mapAddrCounts[node->addr . GetGroup () ].size ();
910
+ naMostConnections = node->addr . GetGroup () ;
911
911
}
912
912
}
913
913
914
- // Reduce to the CNetAddr with the most connections
914
+ // Reduce to the network group with the most connections
915
915
vEvictionCandidates = mapAddrCounts[naMostConnections];
916
916
917
- // Do not disconnect peers who have only 1 evictable connection
917
+ // Do not disconnect peers if there is only 1 connection from their network group
918
918
if (vEvictionCandidates.size () <= 1 )
919
919
// unless we prefer the new connection (for whitelisted peers)
920
920
if (!fPreferNewConnection )
921
921
return false ;
922
922
923
- // Disconnect the most recent connection from the CNetAddr with the most connections
923
+ // Disconnect the most recent connection from the network group with the most connections
924
924
std::sort (vEvictionCandidates.begin (), vEvictionCandidates.end (), ReverseCompareNodeTimeConnected);
925
925
vEvictionCandidates[0 ]->fDisconnect = true ;
926
926
0 commit comments