Check connection no more than once every 30 seconds
This commit is contained in:
parent
23b7bbd548
commit
a6fce1084d
|
@ -1,5 +1,4 @@
|
||||||
using ArgsUniform;
|
using ArgsUniform;
|
||||||
using GethConnector;
|
|
||||||
using Logging;
|
using Logging;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
|
@ -12,6 +11,7 @@ namespace TestNetRewarder
|
||||||
public static CancellationToken CancellationToken { get; private set; }
|
public static CancellationToken CancellationToken { get; private set; }
|
||||||
public static BotClient BotClient { get; private set; } = null!;
|
public static BotClient BotClient { get; private set; } = null!;
|
||||||
private static Processor processor = null!;
|
private static Processor processor = null!;
|
||||||
|
private static DateTime lastCheck = DateTime.MinValue;
|
||||||
|
|
||||||
public static Task Main(string[] args)
|
public static Task Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,9 @@ namespace TestNetRewarder
|
||||||
private static async Task EnsureBotOnline()
|
private static async Task EnsureBotOnline()
|
||||||
{
|
{
|
||||||
var start = DateTime.UtcNow;
|
var start = DateTime.UtcNow;
|
||||||
|
var timeSince = start - lastCheck;
|
||||||
|
if (timeSince.TotalSeconds < 30.0) return;
|
||||||
|
|
||||||
while (! await BotClient.IsOnline() && !CancellationToken.IsCancellationRequested)
|
while (! await BotClient.IsOnline() && !CancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5000);
|
||||||
|
@ -77,6 +80,8 @@ namespace TestNetRewarder
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastCheck = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrintHelp()
|
private static void PrintHelp()
|
||||||
|
|
Loading…
Reference in New Issue