From c5493131664457885f34172e15348db9fb2a95af Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 Feb 2026 22:10:00 -0600 Subject: allow base delay to be sent to ExponentialBackoffDelay --- src/slskd/Common/Compute.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/Compute.cs b/src/slskd/Common/Compute.cs index befceb88..f614d011 100644 --- a/src/slskd/Common/Compute.cs +++ b/src/slskd/Common/Compute.cs @@ -26,14 +26,14 @@ namespace slskd /// public static class Compute { - public static (int Delay, int Jitter) ExponentialBackoffDelay(int iteration, int maxDelayInMilliseconds = int.MaxValue) + public static (int Delay, int Jitter) ExponentialBackoffDelay(int iteration, int baseDelayInMilliseconds = 1000, int maxDelayInMilliseconds = int.MaxValue) { iteration = Math.Min(100, iteration); - var computedDelay = Math.Floor((Math.Pow(2, iteration) - 1) / 2) * 1000; + var computedDelay = Math.Floor((Math.Pow(2, iteration) - 1) / 2) * baseDelayInMilliseconds; var clampedDelay = (int)Math.Min(computedDelay, maxDelayInMilliseconds); - var jitter = new Random().Next(1000); + var jitter = Random.Shared.Next(baseDelayInMilliseconds); return (clampedDelay, jitter); } -- cgit v1.2.3