From a6fce1084dbaa664cb0e2a4dc99713a0e5faefdf Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 19 Feb 2024 15:59:49 +0100 Subject: [PATCH] Check connection no more than once every 30 seconds --- Tools/TestNetRewarder/Program.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tools/TestNetRewarder/Program.cs b/Tools/TestNetRewarder/Program.cs index fbf322c..0aaa41c 100644 --- a/Tools/TestNetRewarder/Program.cs +++ b/Tools/TestNetRewarder/Program.cs @@ -1,5 +1,4 @@ using ArgsUniform; -using GethConnector; using Logging; using Utils; @@ -12,6 +11,7 @@ namespace TestNetRewarder public static CancellationToken CancellationToken { get; private set; } public static BotClient BotClient { get; private set; } = null!; private static Processor processor = null!; + private static DateTime lastCheck = DateTime.MinValue; public static Task Main(string[] args) { @@ -65,6 +65,9 @@ namespace TestNetRewarder private static async Task EnsureBotOnline() { var start = DateTime.UtcNow; + var timeSince = start - lastCheck; + if (timeSince.TotalSeconds < 30.0) return; + while (! await BotClient.IsOnline() && !CancellationToken.IsCancellationRequested) { await Task.Delay(5000); @@ -77,6 +80,8 @@ namespace TestNetRewarder throw new Exception(msg); } } + + lastCheck = start; } private static void PrintHelp()