diff --git a/src/common/net/Client.cpp b/src/common/net/Client.cpp index f4553d97..8ca39775 100644 --- a/src/common/net/Client.cpp +++ b/src/common/net/Client.cpp @@ -6,6 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2016-2018 XMRig , + * Copyright 2018 MoneroOcean , * * 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 ¶ms, 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 ¶ms, 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 ¶ms, 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(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); diff --git a/src/common/net/Client.h b/src/common/net/Client.h index 7efa1f75..f98efe1f 100644 --- a/src/common/net/Client.h +++ b/src/common/net/Client.h @@ -6,6 +6,7 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2016-2018 XMRig , + * Copyright 2018 MoneroOcean , * * 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