From 17a52fb418f8519ef09363145422a5737966d6b2 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:56:07 +0200 Subject: [PATCH] Always reset nonce on RandomX dataset change Also never get a new job when mining is paused --- src/backend/cpu/CpuWorker.cpp | 4 +++- src/backend/cuda/CudaWorker.cpp | 2 +- src/backend/opencl/OclWorker.cpp | 2 +- src/core/Miner.cpp | 5 +++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index d0047e4b7..bef2e898e 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -359,7 +359,9 @@ void xmrig::CpuWorker::start() } } - consumeJob(); + if (!Nonce::isPaused()) { + consumeJob(); + } } } diff --git a/src/backend/cuda/CudaWorker.cpp b/src/backend/cuda/CudaWorker.cpp index 97553637a..a3fd11ef4 100644 --- a/src/backend/cuda/CudaWorker.cpp +++ b/src/backend/cuda/CudaWorker.cpp @@ -158,7 +158,7 @@ void xmrig::CudaWorker::start() std::this_thread::yield(); } - if (!consumeJob()) { + if (isReady() && !consumeJob()) { return; } } diff --git a/src/backend/opencl/OclWorker.cpp b/src/backend/opencl/OclWorker.cpp index 45b92863f..dcac60b71 100644 --- a/src/backend/opencl/OclWorker.cpp +++ b/src/backend/opencl/OclWorker.cpp @@ -190,7 +190,7 @@ void xmrig::OclWorker::start() std::this_thread::yield(); } - if (!consumeJob()) { + if (isReady() && !consumeJob()) { return; } } diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 9cc9092b3..e2b1d596e 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -576,6 +576,11 @@ void xmrig::Miner::setJob(const Job &job, bool donate) # ifdef XMRIG_ALGO_RANDOMX const bool ready = d_ptr->initRX(); + + // Always reset nonce on RandomX dataset change + if (!ready) { + d_ptr->reset = true; + } # else constexpr const bool ready = true; # endif