From e7b6bbffb1786eef842f1e446118a4daa9edf58f Mon Sep 17 00:00:00 2001 From: bitflash-maintainer Date: Wed, 2 Sep 2026 09:04:57 +0000 Subject: worker: back off failed reconnects and say aloud how long the pool has been failing --- src/main.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 0414714..69b2c32 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4394,11 +4394,36 @@ bool BitcoinMiner(int nThreadId) // Participant mode: connect to external pool instead of mining solo/operator if (nMineMode == MINE_PARTICIPANT) { + // An attempt that never got a session backs off (10s doubling to + // 120s) instead of hammering the same path every flat 10s, and a + // streak lasting minutes is said at printf level: the identical + // once-per-10s LogPrint line is how a worker idled all night + // unnoticed (issue #17). A completed session resets both. + int nRetrySecs = 10; + int64 nFailingSince = 0; while (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { - PoolParticipantMiner(); + bool fHadSession = PoolParticipantMiner(); if (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { - LogPrint("worker", "PoolParticipantMiner: reconnecting in 10s\n"); - for (int i = 0; i < 10 && !fShutdown; i++) Sleep(1000); + if (fHadSession) { + nRetrySecs = 10; + nFailingSince = 0; + } else { + if (nFailingSince == 0) + nFailingSince = GetTime(); + int64 nMins = (GetTime() - nFailingSince) / 60; + if (nMins >= 1) + printf("[worker] connection to pool %s has been failing" + " for %lld minutes\n", + strParticipantPool.c_str(), (long long)nMins); + } + LogPrint("worker", "PoolParticipantMiner: reconnecting in %ds\n", + nRetrySecs); + for (int i = 0; i < nRetrySecs && !fShutdown; i++) Sleep(1000); + if (!fHadSession && nRetrySecs < 120) { + nRetrySecs *= 2; + if (nRetrySecs > 120) + nRetrySecs = 120; + } } } return true; -- cgit v1.2.3