mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-14 01:42:55 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0a3bda1c5 | |||
| 6bda7a3c73 | |||
| 69a7a714cd |
@@ -558,7 +558,7 @@ namespace CryptoExchange.Net
|
|||||||
{
|
{
|
||||||
// Handle retry after header
|
// Handle retry after header
|
||||||
var retryAfterHeader = responseHeaders.SingleOrDefault(r => r.Key.Equals("Retry-After", StringComparison.InvariantCultureIgnoreCase));
|
var retryAfterHeader = responseHeaders.SingleOrDefault(r => r.Key.Equals("Retry-After", StringComparison.InvariantCultureIgnoreCase));
|
||||||
if (!retryAfterHeader.Value.Any())
|
if (retryAfterHeader.Value?.Any() != true)
|
||||||
return new ServerRateLimitError(data);
|
return new ServerRateLimitError(data);
|
||||||
|
|
||||||
var value = retryAfterHeader.Value.First();
|
var value = retryAfterHeader.Value.First();
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
<PackageId>CryptoExchange.Net</PackageId>
|
<PackageId>CryptoExchange.Net</PackageId>
|
||||||
<Authors>JKorf</Authors>
|
<Authors>JKorf</Authors>
|
||||||
<Description>A base package for implementing cryptocurrency API's</Description>
|
<Description>A base package for implementing cryptocurrency API's</Description>
|
||||||
<PackageVersion>6.1.1</PackageVersion>
|
<PackageVersion>6.1.2</PackageVersion>
|
||||||
<AssemblyVersion>6.1.1</AssemblyVersion>
|
<AssemblyVersion>6.1.2</AssemblyVersion>
|
||||||
<FileVersion>6.1.1</FileVersion>
|
<FileVersion>6.1.2</FileVersion>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/JKorf/CryptoExchange.Net.git</RepositoryUrl>
|
<RepositoryUrl>https://github.com/JKorf/CryptoExchange.Net.git</RepositoryUrl>
|
||||||
<PackageProjectUrl>https://github.com/JKorf/CryptoExchange.Net</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/JKorf/CryptoExchange.Net</PackageProjectUrl>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<PackageReleaseNotes>6.1.1 - Fixes for json converters</PackageReleaseNotes>
|
<PackageReleaseNotes>6.1.2 - Added support for multiple of the same ratelimiting type in the same rate limiter, Fixed nullreference on rate limit error if no Retry-After header is returned</PackageReleaseNotes>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ namespace CryptoExchange.Net.Objects
|
|||||||
{
|
{
|
||||||
int totalWaitTime = 0;
|
int totalWaitTime = 0;
|
||||||
|
|
||||||
EndpointRateLimiter? endpointLimit;
|
List<EndpointRateLimiter> endpointLimits;
|
||||||
lock (_limiterLock)
|
lock (_limiterLock)
|
||||||
endpointLimit = _limiters.OfType<EndpointRateLimiter>().SingleOrDefault(h => h.Endpoints.Contains(endpoint) && (h.Method == null || h.Method == method));
|
endpointLimits = _limiters.OfType<EndpointRateLimiter>().Where(h => h.Endpoints.Contains(endpoint) && (h.Method == null || h.Method == method)).ToList();
|
||||||
if(endpointLimit != null)
|
foreach (var endpointLimit in endpointLimits)
|
||||||
{
|
{
|
||||||
var waitResult = await ProcessTopic(logger, endpointLimit, endpoint, requestWeight, limitBehaviour, ct).ConfigureAwait(false);
|
var waitResult = await ProcessTopic(logger, endpointLimit, endpoint, requestWeight, limitBehaviour, ct).ConfigureAwait(false);
|
||||||
if (!waitResult)
|
if (!waitResult)
|
||||||
@@ -129,7 +129,7 @@ namespace CryptoExchange.Net.Objects
|
|||||||
totalWaitTime += waitResult.Data;
|
totalWaitTime += waitResult.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endpointLimit?.IgnoreOtherRateLimits == true)
|
if (endpointLimits.Any(l => l.IgnoreOtherRateLimits))
|
||||||
return new CallResult<int>(totalWaitTime);
|
return new CallResult<int>(totalWaitTime);
|
||||||
|
|
||||||
List<PartialEndpointRateLimiter> partialEndpointLimits;
|
List<PartialEndpointRateLimiter> partialEndpointLimits;
|
||||||
@@ -169,10 +169,10 @@ namespace CryptoExchange.Net.Objects
|
|||||||
if(partialEndpointLimits.Any(p => p.IgnoreOtherRateLimits))
|
if(partialEndpointLimits.Any(p => p.IgnoreOtherRateLimits))
|
||||||
return new CallResult<int>(totalWaitTime);
|
return new CallResult<int>(totalWaitTime);
|
||||||
|
|
||||||
ApiKeyRateLimiter? apiLimit;
|
List<ApiKeyRateLimiter> apiLimits;
|
||||||
lock (_limiterLock)
|
lock (_limiterLock)
|
||||||
apiLimit = _limiters.OfType<ApiKeyRateLimiter>().SingleOrDefault(h => h.Type == RateLimitType.ApiKey);
|
apiLimits = _limiters.OfType<ApiKeyRateLimiter>().Where(h => h.Type == RateLimitType.ApiKey).ToList();
|
||||||
if (apiLimit != null)
|
foreach (var apiLimit in apiLimits)
|
||||||
{
|
{
|
||||||
if(apiKey == null)
|
if(apiKey == null)
|
||||||
{
|
{
|
||||||
@@ -206,13 +206,13 @@ namespace CryptoExchange.Net.Objects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((signed || apiLimit?.OnlyForSignedRequests == false) && apiLimit?.IgnoreTotalRateLimit == true)
|
if ((signed || apiLimits.All(l => !l.OnlyForSignedRequests)) && apiLimits.Any(l => l.IgnoreTotalRateLimit))
|
||||||
return new CallResult<int>(totalWaitTime);
|
return new CallResult<int>(totalWaitTime);
|
||||||
|
|
||||||
TotalRateLimiter? totalLimit;
|
List<TotalRateLimiter> totalLimits;
|
||||||
lock (_limiterLock)
|
lock (_limiterLock)
|
||||||
totalLimit = _limiters.OfType<TotalRateLimiter>().SingleOrDefault();
|
totalLimits = _limiters.OfType<TotalRateLimiter>().ToList();
|
||||||
if (totalLimit != null)
|
foreach(var totalLimit in totalLimits)
|
||||||
{
|
{
|
||||||
var waitResult = await ProcessTopic(logger, totalLimit, endpoint, requestWeight, limitBehaviour, ct).ConfigureAwait(false);
|
var waitResult = await ProcessTopic(logger, totalLimit, endpoint, requestWeight, limitBehaviour, ct).ConfigureAwait(false);
|
||||||
if (!waitResult)
|
if (!waitResult)
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d
|
|||||||
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
|
||||||
|
|
||||||
## Release notes
|
## Release notes
|
||||||
|
* Version 6.1.2 - 11 Sep 2023
|
||||||
|
* Added support for multiple of the same ratelimiting type in the same rate limiter
|
||||||
|
* Fixed nullreference on rate limit error if no Retry-After header is returned
|
||||||
|
|
||||||
* Version 6.1.1 - 04 Sep 2023
|
* Version 6.1.1 - 04 Sep 2023
|
||||||
* Fixes for json converters
|
* Fixes for json converters
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user