diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 09:04:57 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 09:04:57 +0000 |
| commit | e7b6bbffb1786eef842f1e446118a4daa9edf58f (patch) | |
| tree | 7563eb36e1e210e06c6ed22d727ba69628f610ae | |
| parent | 014798e50b2de37ed5243c7e622fc290dfda8606 (diff) | |
worker: back off failed reconnects and say aloud how long the pool has been failing
| -rw-r--r-- | src/main.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
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) | |||
| 4394 | // Participant mode: connect to external pool instead of mining solo/operator | 4394 | // Participant mode: connect to external pool instead of mining solo/operator |
| 4395 | if (nMineMode == MINE_PARTICIPANT) | 4395 | if (nMineMode == MINE_PARTICIPANT) |
| 4396 | { | 4396 | { |
| 4397 | // An attempt that never got a session backs off (10s doubling to | ||
| 4398 | // 120s) instead of hammering the same path every flat 10s, and a | ||
| 4399 | // streak lasting minutes is said at printf level: the identical | ||
| 4400 | // once-per-10s LogPrint line is how a worker idled all night | ||
| 4401 | // unnoticed (issue #17). A completed session resets both. | ||
| 4402 | int nRetrySecs = 10; | ||
| 4403 | int64 nFailingSince = 0; | ||
| 4397 | while (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { | 4404 | while (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { |
| 4398 | PoolParticipantMiner(); | 4405 | bool fHadSession = PoolParticipantMiner(); |
| 4399 | if (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { | 4406 | if (fGenerateBitcoins && nMineMode == MINE_PARTICIPANT && !fShutdown) { |
| 4400 | LogPrint("worker", "PoolParticipantMiner: reconnecting in 10s\n"); | 4407 | if (fHadSession) { |
| 4401 | for (int i = 0; i < 10 && !fShutdown; i++) Sleep(1000); | 4408 | nRetrySecs = 10; |
| 4409 | nFailingSince = 0; | ||
| 4410 | } else { | ||
| 4411 | if (nFailingSince == 0) | ||
| 4412 | nFailingSince = GetTime(); | ||
| 4413 | int64 nMins = (GetTime() - nFailingSince) / 60; | ||
| 4414 | if (nMins >= 1) | ||
| 4415 | printf("[worker] connection to pool %s has been failing" | ||
| 4416 | " for %lld minutes\n", | ||
| 4417 | strParticipantPool.c_str(), (long long)nMins); | ||
| 4418 | } | ||
| 4419 | LogPrint("worker", "PoolParticipantMiner: reconnecting in %ds\n", | ||
| 4420 | nRetrySecs); | ||
| 4421 | for (int i = 0; i < nRetrySecs && !fShutdown; i++) Sleep(1000); | ||
| 4422 | if (!fHadSession && nRetrySecs < 120) { | ||
| 4423 | nRetrySecs *= 2; | ||
| 4424 | if (nRetrySecs > 120) | ||
| 4425 | nRetrySecs = 120; | ||
| 4426 | } | ||
| 4402 | } | 4427 | } |
| 4403 | } | 4428 | } |
| 4404 | return true; | 4429 | return true; |