Added pool job algo switch functionality

This commit is contained in:
MoneroOcean 2018-07-18 16:54:21 +02:00
parent 9951bd756d
commit 3b77fc1dbd
2 changed files with 22 additions and 4 deletions

View file

@ -6,6 +6,7 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,6 +34,8 @@
#include "common/log/Log.h"
#include "common/net/Client.h"
#include "net/JobResult.h"
#include "core/Config.h" // for pconfig to access pconfig->get_algo_perf
#include "workers/Workers.h" // to do Workers::switch_algo
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include "rapidjson/stringbuffer.h"
@ -269,10 +272,6 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
return false;
}
if (params.HasMember("algo")) {
job.algorithm().parseAlgorithm(params["algo"].GetString());
}
if (params.HasMember("variant")) {
const rapidjson::Value &variant = params["variant"];
@ -284,6 +283,11 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
}
}
// moved algo after variant parsing to override variant that is considered to be outdated now
if (params.HasMember("algo")) {
job.algorithm().parseAlgorithm(params["algo"].GetString());
}
if (!verifyAlgorithm(job.algorithm())) {
*code = 6;
@ -291,6 +295,9 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
return false;
}
// retarget workers for possible new Algo profile (same algo profile is not reapplied)
Workers::switch_algo(job.algorithm());
if (m_job != job) {
m_jobs++;
m_job = std::move(job);
@ -495,6 +502,16 @@ void Client::login()
}
params.AddMember("algo", algo, allocator);
// addding algo-perf based on pconfig->get_algo_perf
Value algo_perf(kObjectType);
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
Value key(xmrig::Algorithm::perfAlgoName(pa), allocator);
algo_perf.AddMember(key, Value(xmrig::pconfig->get_algo_perf(pa)), allocator);
}
params.AddMember("algo-perf", algo_perf, allocator);
}
doc.AddMember("params", params, allocator);

View file

@ -6,6 +6,7 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by