Fixed miner freeze when switch between RandomX variants.

This commit is contained in:
XMRig 2019-07-28 14:42:29 +07:00
parent ef2454b025
commit ab02bd9847
4 changed files with 15 additions and 0 deletions

View file

@ -52,6 +52,7 @@ public:
virtual const Hashrate *hashrate() const = 0;
virtual const String &profileName() const = 0;
virtual const String &type() const = 0;
virtual void prepare(const Job &nextJob) = 0;
virtual void printHashrate(bool details) = 0;
virtual void setJob(const Job &job) = 0;
virtual void start(IWorker *worker) = 0;

View file

@ -170,6 +170,15 @@ const xmrig::String &xmrig::CpuBackend::type() const
}
void xmrig::CpuBackend::prepare(const Job &nextJob)
{
if (nextJob.algorithm().family() == Algorithm::RANDOM_X && nextJob.algorithm() != d_ptr->algo) {
d_ptr->workers.stop();
d_ptr->threads.clear();
}
}
void xmrig::CpuBackend::printHashrate(bool details)
{
if (!details || !hashrate()) {

View file

@ -49,6 +49,7 @@ protected:
const Hashrate *hashrate() const override;
const String &profileName() const override;
const String &type() const override;
void prepare(const Job &nextJob) override;
void printHashrate(bool details) override;
void setJob(const Job &job) override;
void start(IWorker *worker) override;

View file

@ -352,6 +352,10 @@ void xmrig::Miner::setEnabled(bool enabled)
void xmrig::Miner::setJob(const Job &job, bool donate)
{
for (IBackend *backend : d_ptr->backends) {
backend->prepare(job);
}
uv_rwlock_wrlock(&d_ptr->rwlock);
const uint8_t index = donate ? 1 : 0;