1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00

adjusted some resharper things

This commit is contained in:
JKorf
2018-03-01 12:13:51 +01:00
parent 488eb1cd48
commit e89beed9ef
8 changed files with 20 additions and 30 deletions
+2 -2
View File
@@ -15,11 +15,11 @@ namespace CryptoExchange.Net.RateLimiter
Times = new List<DateTime>();
}
public double GetWaitTime(DateTime time, int limit, TimeSpan perTimePeriod)
public int GetWaitTime(DateTime time, int limit, TimeSpan perTimePeriod)
{
Times.RemoveAll(d => d < time - perTimePeriod);
if (Times.Count >= limit)
return (Times.First() - (time - perTimePeriod)).TotalMilliseconds;
return (int)Math.Round((Times.First() - (time - perTimePeriod)).TotalMilliseconds);
return 0;
}
+5 -5
View File
@@ -12,9 +12,9 @@ namespace CryptoExchange.Net.RateLimiter
{
internal Dictionary<string, RateLimitObject> history = new Dictionary<string, RateLimitObject>();
private int limitPerEndpoint;
private TimeSpan perTimePeriod;
private object historyLock = new object();
private readonly int limitPerEndpoint;
private readonly TimeSpan perTimePeriod;
private readonly object historyLock = new object();
/// <summary>
/// Create a new RateLimiterPerEndpoint. This rate limiter limits the amount of requests per time period to a certain limit, counts the request per endpoint.
@@ -29,7 +29,7 @@ namespace CryptoExchange.Net.RateLimiter
public double LimitRequest(string url)
{
double waitTime;
int waitTime;
RateLimitObject rlo;
lock (historyLock)
{
@@ -50,7 +50,7 @@ namespace CryptoExchange.Net.RateLimiter
if (waitTime != 0)
{
Thread.Sleep(Convert.ToInt32(waitTime));
waitTime += sw.ElapsedMilliseconds;
waitTime += (int)sw.ElapsedMilliseconds;
}
rlo.Add(DateTime.UtcNow);
+3 -3
View File
@@ -13,9 +13,9 @@ namespace CryptoExchange.Net.RateLimiter
{
internal List<DateTime> history = new List<DateTime>();
private int limit;
private TimeSpan perTimePeriod;
private object requestLock = new object();
private readonly int limit;
private readonly TimeSpan perTimePeriod;
private readonly object requestLock = new object();
/// <summary>
/// Create a new RateLimiterTotal. This rate limiter limits the amount of requests per time period to a certain limit, counts the total amount of requests.