diff --git a/src/Nethermind/Nethermind.Core.Test/RateLimiterTests.cs b/src/Nethermind/Nethermind.Core.Test/RateLimiterTests.cs index 2db52069ae4..84d4f1a653d 100644 --- a/src/Nethermind/Nethermind.Core.Test/RateLimiterTests.cs +++ b/src/Nethermind/Nethermind.Core.Test/RateLimiterTests.cs @@ -48,7 +48,7 @@ public async Task RateLimiter_should_throw_when_cancelled() RateLimiter rateLimiter = new(1); await rateLimiter.WaitAsync(CancellationToken.None); CancellationTokenSource cts = new(); - ValueTask waitTask = rateLimiter.WaitAsync(cts.Token); + Task waitTask = rateLimiter.WaitAsync(cts.Token); cts.Cancel(); Func act = async () => await waitTask; diff --git a/src/Nethermind/Nethermind.Core/RateLimiter.cs b/src/Nethermind/Nethermind.Core/RateLimiter.cs index 7b443f62443..de66ad7139d 100644 --- a/src/Nethermind/Nethermind.Core/RateLimiter.cs +++ b/src/Nethermind/Nethermind.Core/RateLimiter.cs @@ -48,7 +48,7 @@ public bool IsThrottled() return GetCurrentTick() < _nextSlot; } - public async ValueTask WaitAsync(CancellationToken ctx) + public Task WaitAsync(CancellationToken ctx) { long currentNextSlot = _nextSlot; while (true) @@ -64,8 +64,8 @@ public async ValueTask WaitAsync(CancellationToken ctx) long now = GetCurrentTick(); long toWait = currentNextSlot - now; - if (toWait <= 0) return; + if (toWait <= 0) return Task.CompletedTask; - await Task.Delay(TimeSpan.FromMilliseconds(TickToMs(toWait)), ctx); + return Task.Delay(TimeSpan.FromMilliseconds(TickToMs(toWait)), ctx); } }