mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-07 16:06:15 +00:00
Added ExchangeType enum, some small improvements
This commit is contained in:
parent
e650771d16
commit
625dccbbe4
@ -624,7 +624,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
paramString = $" with request body '{request.Content}'";
|
paramString = $" with request body '{request.Content}'";
|
||||||
|
|
||||||
var headers = request.GetHeaders();
|
var headers = request.GetHeaders();
|
||||||
if (headers.Any())
|
if (headers.Count != 0)
|
||||||
paramString += " with headers " + string.Join(", ", headers.Select(h => h.Key + $"=[{string.Join(",", h.Value)}]"));
|
paramString += " with headers " + string.Join(", ", headers.Select(h => h.Key + $"=[{string.Join(",", h.Value)}]"));
|
||||||
|
|
||||||
TotalRequestsMade++;
|
TotalRequestsMade++;
|
||||||
@ -908,8 +908,8 @@ namespace CryptoExchange.Net.Clients
|
|||||||
{
|
{
|
||||||
// Write the parameters as json in the body
|
// Write the parameters as json in the body
|
||||||
string stringData;
|
string stringData;
|
||||||
if (parameters.Count == 1 && parameters.ContainsKey(Constants.BodyPlaceHolderKey))
|
if (parameters.Count == 1 && parameters.TryGetValue(Constants.BodyPlaceHolderKey, out object? value))
|
||||||
stringData = CreateSerializer().Serialize(parameters[Constants.BodyPlaceHolderKey]);
|
stringData = CreateSerializer().Serialize(value);
|
||||||
else
|
else
|
||||||
stringData = CreateSerializer().Serialize(parameters);
|
stringData = CreateSerializer().Serialize(parameters);
|
||||||
request.SetContent(stringData, contentType);
|
request.SetContent(stringData, contentType);
|
||||||
|
@ -235,4 +235,18 @@
|
|||||||
Cache
|
Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Type of exchange
|
||||||
|
/// </summary>
|
||||||
|
public enum ExchangeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Centralized
|
||||||
|
/// </summary>
|
||||||
|
CEX,
|
||||||
|
/// <summary>
|
||||||
|
/// Decentralized
|
||||||
|
/// </summary>
|
||||||
|
DEX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,12 +82,12 @@ namespace CryptoExchange.Net.Objects
|
|||||||
TimeSyncState.LastSyncTime = DateTime.UtcNow;
|
TimeSyncState.LastSyncTime = DateTime.UtcNow;
|
||||||
if (offset.TotalMilliseconds > 0 && offset.TotalMilliseconds < 500)
|
if (offset.TotalMilliseconds > 0 && offset.TotalMilliseconds < 500)
|
||||||
{
|
{
|
||||||
Logger.Log(LogLevel.Information, $"{TimeSyncState.ApiName} Time offset within limits, set offset to 0ms");
|
Logger.Log(LogLevel.Information, "{TimeSyncState.ApiName} Time offset within limits, set offset to 0ms", TimeSyncState.ApiName);
|
||||||
TimeSyncState.TimeOffset = TimeSpan.Zero;
|
TimeSyncState.TimeOffset = TimeSpan.Zero;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Log(LogLevel.Information, $"{TimeSyncState.ApiName} Time offset set to {Math.Round(offset.TotalMilliseconds)}ms");
|
Logger.Log(LogLevel.Information, "{TimeSyncState.ApiName} Time offset set to {Offset}ms", TimeSyncState.ApiName, Math.Round(offset.TotalMilliseconds));
|
||||||
TimeSyncState.TimeOffset = offset;
|
TimeSyncState.TimeOffset = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace CryptoExchange.Net.Requests
|
|||||||
_httpClient = CreateClient(proxy, requestTimeout);
|
_httpClient = CreateClient(proxy, requestTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpClient CreateClient(ApiProxy? proxy, TimeSpan requestTimeout)
|
private static HttpClient CreateClient(ApiProxy? proxy, TimeSpan requestTimeout)
|
||||||
{
|
{
|
||||||
var handler = new HttpClientHandler();
|
var handler = new HttpClientHandler();
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user