diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-02-17 22:10:00 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-03-15 11:14:07 -0500 |
| commit | 6f4c91344d5e4be512dec16600e805cc17178365 (patch) | |
| tree | 62acfd235978ac7abe11a9e516b1a646fb012611 /src | |
| parent | db77adb4c086fe1166449c13af88e2e3bef6590a (diff) | |
| download | slskd-6f4c91344d5e4be512dec16600e805cc17178365.tar.gz | |
allow base delay to be sent to ExponentialBackoffDelay
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Compute.cs | 6 |
1 files changed, 3 insertions, 3 deletions
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 /// </summary> 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); } |
