1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2026-02-16 22:23:54 +00:00

Compare commits

..

No commits in common. "90c1b89ceb2d8b58671ec578db8bdb00dfab7893" and "5942423bfb239adefaac1f5265d36481dcef19b3" have entirely different histories.

2 changed files with 6 additions and 36 deletions

View File

@ -643,20 +643,19 @@ namespace CryptoExchange.Net.OrderBook
/// <summary>
/// Wait until an update has been buffered
/// </summary>
/// <param name="minWait">Min wait time</param>
/// <param name="maxWait">Max wait time</param>
/// <param name="timeout">Max wait time</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
protected async Task<CallResult> WaitUntilFirstUpdateBufferedAsync(TimeSpan? minWait, TimeSpan maxWait, CancellationToken ct)
protected async Task<CallResult<bool>> WaitUntilFirstUpdateBufferedAsync(TimeSpan timeout, CancellationToken ct)
{
var startWait = DateTime.UtcNow;
while (_processBuffer.Count == 0)
{
if (ct.IsCancellationRequested)
return new CallResult(new CancellationRequestedError());
return new CallResult<bool>(new CancellationRequestedError());
if (DateTime.UtcNow - startWait > maxWait)
return new CallResult(new ServerError(new ErrorInfo(ErrorType.OrderBookTimeout, "Timeout while waiting for data")));
if (DateTime.UtcNow - startWait > timeout)
return new CallResult<bool>(new ServerError(new ErrorInfo(ErrorType.OrderBookTimeout, "Timeout while waiting for data")));
try
{
@ -666,14 +665,7 @@ namespace CryptoExchange.Net.OrderBook
{ }
}
if (minWait != null)
{
var dif = DateTime.UtcNow - startWait;
if (dif < minWait)
await Task.Delay(minWait.Value - dif).ConfigureAwait(false);
}
return CallResult.SuccessResult;
return new CallResult<bool>(true);
}
/// <summary>

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -141,26 +139,6 @@ namespace CryptoExchange.Net
/// <param name="api">API name</param>
public static TimeSpan? GetSocketOffset(string api) => _lastSocketDelays.TryGetValue(api, out var val) && val.Offset != null ? TimeSpan.FromMilliseconds(val.Offset.Value) : null;
/// <summary>
/// Get a dictionary of API/Client name -> time offset for Rest api's
/// </summary>
public static Dictionary<string, TimeSpan?> GetRestOffsets()
{
return _lastRestDelays.ToDictionary(
x => x.Key,
x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value)));
}
/// <summary>
/// Get a dictionary of API/Client name -> time offset for Websocket api's
/// </summary>
public static Dictionary<string, TimeSpan?> GetWebsocketOffsets()
{
return _lastSocketDelays.ToDictionary(
x => x.Key,
x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value)));
}
/// <summary>
/// Reset the WebSocket API update timestamp to trigger a new time offset calculation
/// </summary>