From d451c18821e94d2d78b0a8fcbbb5a710765dd174 Mon Sep 17 00:00:00 2001 From: JKorf Date: Sun, 12 Jun 2022 15:21:22 +0200 Subject: [PATCH] No longer waiting for timesyncing to complete when it's not the first request --- CryptoExchange.Net/Clients/BaseRestClient.cs | 14 ++++++++++---- CryptoExchange.Net/Clients/RestApiClient.cs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CryptoExchange.Net/Clients/BaseRestClient.cs b/CryptoExchange.Net/Clients/BaseRestClient.cs index b02357f..b02772e 100644 --- a/CryptoExchange.Net/Clients/BaseRestClient.cs +++ b/CryptoExchange.Net/Clients/BaseRestClient.cs @@ -172,11 +172,17 @@ namespace CryptoExchange.Net if (signed) { - var syncTimeResult = await apiClient.SyncTimeAsync().ConfigureAwait(false); - if (!syncTimeResult) + var syncTask = apiClient.SyncTimeAsync(); + var timeSyncInfo = apiClient.GetTimeSyncInfo(); + if (timeSyncInfo.TimeSyncState.LastSyncTime == default) { - log.Write(LogLevel.Debug, $"[{requestId}] Failed to sync time, aborting request: " + syncTimeResult.Error); - return syncTimeResult.As(default); + // Initially with first request we'll need to wait for the time syncing, if it's not the first request we can just continue + var syncTimeResult = await syncTask.ConfigureAwait(false); + if (!syncTimeResult) + { + log.Write(LogLevel.Debug, $"[{requestId}] Failed to sync time, aborting request: " + syncTimeResult.Error); + return syncTimeResult.As(default); + } } } diff --git a/CryptoExchange.Net/Clients/RestApiClient.cs b/CryptoExchange.Net/Clients/RestApiClient.cs index 2112c21..53fa555 100644 --- a/CryptoExchange.Net/Clients/RestApiClient.cs +++ b/CryptoExchange.Net/Clients/RestApiClient.cs @@ -18,7 +18,7 @@ namespace CryptoExchange.Net /// Get time sync info for an API client /// /// - protected abstract TimeSyncInfo GetTimeSyncInfo(); + public abstract TimeSyncInfo GetTimeSyncInfo(); /// /// Get time offset for an API client