From 2460cf84334f77be9515c1674a3d710a34479bc9 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 27 Apr 2024 18:42:05 -0500 Subject: deduplicate entries --- src/slskd/Core/Blacklist.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Blacklist.cs b/src/slskd/Core/Blacklist.cs index 4a47b8a8..7b1a46c6 100644 --- a/src/slskd/Core/Blacklist.cs +++ b/src/slskd/Core/Blacklist.cs @@ -268,13 +268,17 @@ public class Blacklist } // copy working dictionary to a temporary cache to: - // * convert List<> to array to increase access speed + // * deduplicate entries // * sort arrays by first IP to enable binary search (future?) + // * convert List<> to array to increase access speed var tempCache = new ConcurrentDictionary(); foreach (var key in dict.Keys) { - tempCache[key] = dict[key].OrderBy(x => x.First).ToArray(); + tempCache[key] = dict[key] + .Distinct() + .OrderBy(x => x.First) + .ToArray(); } // swap the temporary cache for the "real" cache, enabling a bumpless update -- cgit v1.2.3