From e2c6c857671d95b8c1c6874e67711015eed060e9 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Sat, 5 Aug 2023 20:35:39 +0200 Subject: [PATCH] Randomize interval between connection retries Add a random delay between 1 and 15 secs --- src/mining.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mining.cpp b/src/mining.cpp index ecfd283..b09e500 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -65,10 +65,10 @@ bool checkPoolConnection(void) { WiFi.hostByName(poolString, serverIP); Serial.printf("Resolved DNS got: %s\n", serverIP.toString()); vTaskDelay(1000 / portTICK_PERIOD_MS); - return true; + return false; } - return false; + return true; } //Implements a socketKeepAlive function and @@ -144,8 +144,10 @@ void runStratumWorker(void *name) { //strcpy(btcString,"test"); if(!checkPoolConnection()) - //If server not reachable add 5sec delay bettween connection petitions - vTaskDelay(5000 / portTICK_PERIOD_MS); + //If server is not reachable add random delay for connection retries + srand(millis()); + //Generate value between 1 and 15 secs + vTaskDelay(((1 + rand() % 15) * 1000) / portTICK_PERIOD_MS); if(!isMinerSuscribed){