getMostFrequentlyUsedProxies method

List<ProxyModel> getMostFrequentlyUsedProxies({
  1. int count = 10,
})

Gets the most frequently used proxies

Implementation

List<ProxyModel> getMostFrequentlyUsedProxies({int count = 10}) {
  final allProxies = getAllProxies();

  // Sort by usage count (highest first)
  allProxies.sort((a, b) {
    final aKey = '${a.ip}:${a.port}';
    final bKey = '${b.ip}:${b.port}';
    final aCount = _usageStats[aKey] ?? 0;
    final bCount = _usageStats[bKey] ?? 0;
    return bCount.compareTo(aCount);
  });

  // Return the top N proxies
  return allProxies.take(count).toList();
}