fix(mining): restore the miner after a benchmark only if it was running
Cancelling a thread benchmark always stopped and restarted the pool miner at its pre-benchmark thread count, even when the user had not been mining before the benchmark began. That silently started the miner on a plain cancel or a switch to solo mode. - A cancel now always drops the candidate-thread miner, and restarts the pool miner only when the user was mining before the benchmark, read from a snapshot taken at the start rather than the live running state (the benchmark sweep transiently stops the miner between candidates, so a live check would drop the restore). - Callers that must not restore the miner (leaving solo mode) pass the new restore flag as false. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -55,17 +55,16 @@ bool IsMiningBenchmarkActive() {
|
||||
return s_benchmark.active();
|
||||
}
|
||||
|
||||
void CancelMiningBenchmark(App* app) {
|
||||
void CancelMiningBenchmark(App* app, bool restoreMiner) {
|
||||
if (!s_benchmark.active()) return;
|
||||
const int restoreThreads = s_benchmark.prev_threads;
|
||||
const ThreadBenchmarkCancel plan = PlanThreadBenchmarkCancel(s_benchmark); // read BEFORE reset() zeroes both fields
|
||||
s_benchmark.reset();
|
||||
// Restore the miner to its pre-benchmark thread count. A benchmark runs in pool mode, so restore
|
||||
// regardless of the instantaneous running state — the sweep may be mid inter-candidate stop, where an
|
||||
// isPoolMinerRunning() check would be transiently false and silently drop the restart. (L-04, L-11)
|
||||
if (app && restoreThreads > 0) {
|
||||
app->stopPoolMining();
|
||||
app->startPoolMining(restoreThreads);
|
||||
}
|
||||
if (!app) return;
|
||||
// Always drop the candidate-thread miner. Restore only if the user was mining before the benchmark, using the
|
||||
// was_pool_running SNAPSHOT (not the live state: the sweep may be mid inter-candidate stop). (L-04, L-11)
|
||||
app->stopPoolMining();
|
||||
if (restoreMiner && plan.restartMiner)
|
||||
app->startPoolMining(plan.restartThreads);
|
||||
}
|
||||
|
||||
// Miner-update version check (one shot per session): fetches the latest DRG-XMRig release tag in
|
||||
|
||||
Reference in New Issue
Block a user