mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 10:01:06 +00:00
Restored algo field in login request.
This commit is contained in:
parent
f590cf58fb
commit
0ab26a1619
14 changed files with 129 additions and 35 deletions
|
@ -174,6 +174,10 @@ void xmrig::CpuWorker<N>::start()
|
||||||
|
|
||||||
const Job &job = m_job.currentJob();
|
const Job &job = m_job.currentJob();
|
||||||
|
|
||||||
|
if (job.algorithm().memory() != m_algorithm.memory()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
||||||
randomx_calculate_hash(m_vm->get(), m_job.blob(), job.size(), m_hash);
|
randomx_calculate_hash(m_vm->get(), m_job.blob(), job.size(), m_hash);
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define XMRIG_ISTRATEGYLISTENER_H
|
#define XMRIG_ISTRATEGYLISTENER_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -45,6 +45,7 @@ public:
|
||||||
|
|
||||||
virtual void onActive(IStrategy *strategy, IClient *client) = 0;
|
virtual void onActive(IStrategy *strategy, IClient *client) = 0;
|
||||||
virtual void onJob(IStrategy *strategy, IClient *client, const Job &job) = 0;
|
virtual void onJob(IStrategy *strategy, IClient *client, const Job &job) = 0;
|
||||||
|
virtual void onLogin(IStrategy *strategy, IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) = 0;
|
||||||
virtual void onPause(IStrategy *strategy) = 0;
|
virtual void onPause(IStrategy *strategy) = 0;
|
||||||
virtual void onResultAccepted(IStrategy *strategy, IClient *client, const SubmitResult &result, const char *error) = 0;
|
virtual void onResultAccepted(IStrategy *strategy, IClient *client, const SubmitResult &result, const char *error) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -575,19 +575,6 @@ void xmrig::Client::login()
|
||||||
params.AddMember("rigid", m_pool.rigId().toJSON(), allocator);
|
params.AddMember("rigid", m_pool.rigId().toJSON(), allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//# ifdef XMRIG_PROXY_PROJECT FIXME
|
|
||||||
// if (m_pool.algorithm().variant() != xmrig::VARIANT_AUTO)
|
|
||||||
//# endif
|
|
||||||
// {
|
|
||||||
// Value algo(kArrayType);
|
|
||||||
|
|
||||||
// for (const auto &a : m_pool.algorithms()) {
|
|
||||||
// algo.PushBack(StringRef(a.shortName()), allocator);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// params.AddMember("algo", algo, allocator);
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_listener->onLogin(this, doc, params);
|
m_listener->onLogin(this, doc, params);
|
||||||
|
|
||||||
JsonRequest::create(doc, 1, "login", params);
|
JsonRequest::create(doc, 1, "login", params);
|
||||||
|
|
|
@ -113,7 +113,7 @@ void xmrig::FailoverStrategy::resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
|
void xmrig::FailoverStrategy::setAlgo(const Algorithm &algo)
|
||||||
{
|
{
|
||||||
for (IClient *client : m_pools) {
|
for (IClient *client : m_pools) {
|
||||||
client->setAlgo(algo);
|
client->setAlgo(algo);
|
||||||
|
@ -163,6 +163,12 @@ void xmrig::FailoverStrategy::onClose(IClient *client, int failures)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::FailoverStrategy::onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
|
{
|
||||||
|
m_listener->onLogin(this, client, doc, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::FailoverStrategy::onJobReceived(IClient *client, const Job &job, const rapidjson::Value &)
|
void xmrig::FailoverStrategy::onJobReceived(IClient *client, const Job &job, const rapidjson::Value &)
|
||||||
{
|
{
|
||||||
if (m_active == client->id()) {
|
if (m_active == client->id()) {
|
||||||
|
|
|
@ -51,9 +51,8 @@ public:
|
||||||
void add(const Pool &pool);
|
void add(const Pool &pool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline bool isActive() const override { return m_active >= 0; }
|
inline bool isActive() const override { return m_active >= 0; }
|
||||||
inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; }
|
inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; }
|
||||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
|
||||||
|
|
||||||
int64_t submit(const JobResult &result) override;
|
int64_t submit(const JobResult &result) override;
|
||||||
void connect() override;
|
void connect() override;
|
||||||
|
@ -64,6 +63,7 @@ protected:
|
||||||
|
|
||||||
void onClose(IClient *client, int failures) override;
|
void onClose(IClient *client, int failures) override;
|
||||||
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||||
|
void onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
||||||
void onLoginSuccess(IClient *client) override;
|
void onLoginSuccess(IClient *client) override;
|
||||||
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void xmrig::SinglePoolStrategy::resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::SinglePoolStrategy::setAlgo(const xmrig::Algorithm &algo)
|
void xmrig::SinglePoolStrategy::setAlgo(const Algorithm &algo)
|
||||||
{
|
{
|
||||||
m_client->setAlgo(algo);
|
m_client->setAlgo(algo);
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,12 @@ void xmrig::SinglePoolStrategy::onJobReceived(IClient *client, const Job &job, c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::SinglePoolStrategy::onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
|
{
|
||||||
|
m_listener->onLogin(this, client, doc, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::SinglePoolStrategy::onLoginSuccess(IClient *client)
|
void xmrig::SinglePoolStrategy::onLoginSuccess(IClient *client)
|
||||||
{
|
{
|
||||||
m_active = true;
|
m_active = true;
|
||||||
|
|
|
@ -45,9 +45,8 @@ public:
|
||||||
~SinglePoolStrategy() override;
|
~SinglePoolStrategy() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline bool isActive() const override { return m_active; }
|
inline bool isActive() const override { return m_active; }
|
||||||
inline IClient *client() const override { return m_client; }
|
inline IClient *client() const override { return m_client; }
|
||||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
|
||||||
|
|
||||||
int64_t submit(const JobResult &result) override;
|
int64_t submit(const JobResult &result) override;
|
||||||
void connect() override;
|
void connect() override;
|
||||||
|
@ -58,6 +57,7 @@ protected:
|
||||||
|
|
||||||
void onClose(IClient *client, int failures) override;
|
void onClose(IClient *client, int failures) override;
|
||||||
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||||
|
void onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
||||||
void onLoginSuccess(IClient *client) override;
|
void onLoginSuccess(IClient *client) override;
|
||||||
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
||||||
|
|
||||||
|
|
|
@ -62,17 +62,46 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isEnabled(const Algorithm &algorithm) const
|
||||||
|
{
|
||||||
|
for (IBackend *backend : backends) {
|
||||||
|
if (backend->isEnabled(algorithm)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void rebuild()
|
||||||
|
{
|
||||||
|
algorithms.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < Algorithm::MAX; ++i) {
|
||||||
|
const Algorithm algo(static_cast<Algorithm::Id>(i));
|
||||||
|
|
||||||
|
if (isEnabled(algo)) {
|
||||||
|
algorithms.push_back(algo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void handleJobChange()
|
inline void handleJobChange()
|
||||||
{
|
{
|
||||||
active = true;
|
active = true;
|
||||||
if (enabled) {
|
|
||||||
Nonce::pause(false);;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IBackend *backend : backends) {
|
for (IBackend *backend : backends) {
|
||||||
backend->setJob(job);
|
backend->setJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
Nonce::pause(false);;
|
||||||
|
}
|
||||||
|
|
||||||
|
Nonce::reset(job.index());
|
||||||
|
|
||||||
if (ticks == 0) {
|
if (ticks == 0) {
|
||||||
ticks++;
|
ticks++;
|
||||||
timer->start(500, 500);
|
timer->start(500, 500);
|
||||||
|
@ -80,6 +109,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Algorithms algorithms;
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
Controller *controller;
|
Controller *controller;
|
||||||
|
@ -104,6 +134,8 @@ xmrig::Miner::Miner(Controller *controller)
|
||||||
d_ptr->timer = new Timer(this);
|
d_ptr->timer = new Timer(this);
|
||||||
|
|
||||||
d_ptr->backends.push_back(new CpuBackend(controller));
|
d_ptr->backends.push_back(new CpuBackend(controller));
|
||||||
|
|
||||||
|
d_ptr->rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,6 +151,12 @@ bool xmrig::Miner::isEnabled() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const xmrig::Algorithms &xmrig::Miner::algorithms() const
|
||||||
|
{
|
||||||
|
return d_ptr->algorithms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
|
const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
|
||||||
{
|
{
|
||||||
return d_ptr->backends;
|
return d_ptr->backends;
|
||||||
|
@ -202,8 +240,6 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
|
||||||
d_ptr->job = job;
|
d_ptr->job = job;
|
||||||
d_ptr->job.setIndex(index);
|
d_ptr->job.setIndex(index);
|
||||||
|
|
||||||
Nonce::reset(index);
|
|
||||||
|
|
||||||
uv_rwlock_wrunlock(&d_ptr->rwlock);
|
uv_rwlock_wrunlock(&d_ptr->rwlock);
|
||||||
|
|
||||||
d_ptr->handleJobChange();
|
d_ptr->handleJobChange();
|
||||||
|
@ -222,6 +258,8 @@ void xmrig::Miner::stop()
|
||||||
|
|
||||||
void xmrig::Miner::onConfigChanged(Config *config, Config *previousConfig)
|
void xmrig::Miner::onConfigChanged(Config *config, Config *previousConfig)
|
||||||
{
|
{
|
||||||
|
d_ptr->rebuild();
|
||||||
|
|
||||||
if (config->pools() != previousConfig->pools() && config->pools().active() > 0) {
|
if (config->pools() != previousConfig->pools() && config->pools().active() > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IBaseListener.h"
|
#include "base/kernel/interfaces/IBaseListener.h"
|
||||||
#include "base/kernel/interfaces/ITimerListener.h"
|
#include "base/kernel/interfaces/ITimerListener.h"
|
||||||
|
#include "crypto/common/Algorithm.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -49,6 +50,7 @@ public:
|
||||||
~Miner() override;
|
~Miner() override;
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
const Algorithms &algorithms() const;
|
||||||
const std::vector<IBackend *> &backends() const;
|
const std::vector<IBackend *> &backends() const;
|
||||||
Job job() const;
|
Job job() const;
|
||||||
void pause();
|
void pause();
|
||||||
|
|
|
@ -115,7 +115,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<xmrig::Algorithm> Algorithms;
|
typedef std::vector<Algorithm> Algorithms;
|
||||||
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
|
@ -154,6 +154,21 @@ void xmrig::Network::onJobResult(const JobResult &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Network::onLogin(IStrategy *, IClient *, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
Value algo(kArrayType);
|
||||||
|
|
||||||
|
for (const auto &a : m_controller->miner()->algorithms()) {
|
||||||
|
algo.PushBack(StringRef(a.shortName()), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.AddMember("algo", algo, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Network::onPause(IStrategy *strategy)
|
void xmrig::Network::onPause(IStrategy *strategy)
|
||||||
{
|
{
|
||||||
if (m_donate && m_donate == strategy) {
|
if (m_donate && m_donate == strategy) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
||||||
void onConfigChanged(Config *config, Config *previousConfig) override;
|
void onConfigChanged(Config *config, Config *previousConfig) override;
|
||||||
void onJob(IStrategy *strategy, IClient *client, const Job &job) override;
|
void onJob(IStrategy *strategy, IClient *client, const Job &job) override;
|
||||||
void onJobResult(const JobResult &result) override;
|
void onJobResult(const JobResult &result) override;
|
||||||
|
void onLogin(IStrategy *strategy, IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
||||||
void onPause(IStrategy *strategy) override;
|
void onPause(IStrategy *strategy) override;
|
||||||
void onRequest(IApiRequest &request) override;
|
void onRequest(IApiRequest &request) override;
|
||||||
void onResultAccepted(IStrategy *strategy, IClient *client, const SubmitResult &result, const char *error) override;
|
void onResultAccepted(IStrategy *strategy, IClient *client, const SubmitResult &result, const char *error) override;
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
|
||||||
#include "base/kernel/Platform.h"
|
#include "base/kernel/Platform.h"
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
#include "base/tools/Timer.h"
|
#include "base/tools/Timer.h"
|
||||||
#include "core/config/Config.h"
|
#include "core/config/Config.h"
|
||||||
#include "core/Controller.h"
|
#include "core/Controller.h"
|
||||||
|
#include "core/Miner.h"
|
||||||
#include "crypto/common/keccak.h"
|
#include "crypto/common/keccak.h"
|
||||||
#include "net/Network.h"
|
#include "net/Network.h"
|
||||||
#include "net/strategies/DonateStrategy.h"
|
#include "net/strategies/DonateStrategy.h"
|
||||||
|
@ -57,10 +60,10 @@ static const char *kDonateHostTls = "donate.ssl.xmrig.com";
|
||||||
xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener *listener) :
|
xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener *listener) :
|
||||||
m_tls(false),
|
m_tls(false),
|
||||||
m_userId(),
|
m_userId(),
|
||||||
m_proxy(nullptr),
|
|
||||||
m_donateTime(static_cast<uint64_t>(controller->config()->pools().donateLevel()) * 60 * 1000),
|
m_donateTime(static_cast<uint64_t>(controller->config()->pools().donateLevel()) * 60 * 1000),
|
||||||
m_idleTime((100 - static_cast<uint64_t>(controller->config()->pools().donateLevel())) * 60 * 1000),
|
m_idleTime((100 - static_cast<uint64_t>(controller->config()->pools().donateLevel())) * 60 * 1000),
|
||||||
m_controller(controller),
|
m_controller(controller),
|
||||||
|
m_proxy(nullptr),
|
||||||
m_strategy(nullptr),
|
m_strategy(nullptr),
|
||||||
m_listener(listener),
|
m_listener(listener),
|
||||||
m_state(STATE_NEW),
|
m_state(STATE_NEW),
|
||||||
|
@ -78,10 +81,6 @@ xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener
|
||||||
# endif
|
# endif
|
||||||
m_pools.push_back(Pool(kDonateHost, 3333, m_userId, nullptr, 0, true));
|
m_pools.push_back(Pool(kDonateHost, 3333, m_userId, nullptr, 0, true));
|
||||||
|
|
||||||
// for (Pool &pool : m_pools) {
|
|
||||||
// pool.adjust(Algorithm()); // FIXME
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (m_pools.size() > 1) {
|
if (m_pools.size() > 1) {
|
||||||
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
|
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
|
||||||
}
|
}
|
||||||
|
@ -129,6 +128,8 @@ void xmrig::DonateStrategy::connect()
|
||||||
|
|
||||||
void xmrig::DonateStrategy::setAlgo(const xmrig::Algorithm &algo)
|
void xmrig::DonateStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||||
{
|
{
|
||||||
|
m_algorithm = algo;
|
||||||
|
|
||||||
m_strategy->setAlgo(algo);
|
m_strategy->setAlgo(algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,13 +186,14 @@ void xmrig::DonateStrategy::onClose(IClient *, int failures)
|
||||||
|
|
||||||
void xmrig::DonateStrategy::onLogin(IClient *, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
void xmrig::DonateStrategy::onLogin(IClient *, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
{
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
if (m_tls) {
|
if (m_tls) {
|
||||||
char buf[40] = { 0 };
|
char buf[40] = { 0 };
|
||||||
snprintf(buf, sizeof(buf), "stratum+ssl://%s", m_pools[0].url().data());
|
snprintf(buf, sizeof(buf), "stratum+ssl://%s", m_pools[0].url().data());
|
||||||
params.AddMember("url", rapidjson::Value(buf, allocator), allocator);
|
params.AddMember("url", Value(buf, allocator), allocator);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
params.AddMember("url", m_pools[1].url().toJSON(), allocator);
|
params.AddMember("url", m_pools[1].url().toJSON(), allocator);
|
||||||
|
@ -199,6 +201,14 @@ void xmrig::DonateStrategy::onLogin(IClient *, rapidjson::Document &doc, rapidjs
|
||||||
# else
|
# else
|
||||||
params.AddMember("url", m_pools[0].url().toJSON(), allocator);
|
params.AddMember("url", m_pools[0].url().toJSON(), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
setAlgorithms(doc, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::DonateStrategy::onLogin(IStrategy *, IClient *, rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
|
{
|
||||||
|
setAlgorithms(doc, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,6 +260,27 @@ void xmrig::DonateStrategy::idle(double min, double max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::DonateStrategy::setAlgorithms(rapidjson::Document &doc, rapidjson::Value ¶ms)
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
Algorithms algorithms = m_controller->miner()->algorithms();
|
||||||
|
const size_t index = static_cast<size_t>(std::distance(algorithms.begin(), std::find(algorithms.begin(), algorithms.end(), m_algorithm)));
|
||||||
|
if (index > 0 && index < algorithms.size()) {
|
||||||
|
std::swap(algorithms[0], algorithms[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Value algo(kArrayType);
|
||||||
|
|
||||||
|
for (const auto &a : algorithms) {
|
||||||
|
algo.PushBack(StringRef(a.shortName()), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.AddMember("algo", algo, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::DonateStrategy::setJob(IClient *client, const Job &job)
|
void xmrig::DonateStrategy::setJob(IClient *client, const Job &job)
|
||||||
{
|
{
|
||||||
if (isActive()) {
|
if (isActive()) {
|
||||||
|
|
|
@ -70,6 +70,7 @@ protected:
|
||||||
|
|
||||||
void onClose(IClient *client, int failures) override;
|
void onClose(IClient *client, int failures) override;
|
||||||
void onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
void onLogin(IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
||||||
|
void onLogin(IStrategy *strategy, IClient *client, rapidjson::Document &doc, rapidjson::Value ¶ms) override;
|
||||||
void onLoginSuccess(IClient *client) override;
|
void onLoginSuccess(IClient *client) override;
|
||||||
|
|
||||||
void onTimer(const Timer *timer) override;
|
void onTimer(const Timer *timer) override;
|
||||||
|
@ -87,16 +88,18 @@ private:
|
||||||
|
|
||||||
Client *createProxy();
|
Client *createProxy();
|
||||||
void idle(double min, double max);
|
void idle(double min, double max);
|
||||||
|
void setAlgorithms(rapidjson::Document &doc, rapidjson::Value ¶ms);
|
||||||
void setJob(IClient *client, const Job &job);
|
void setJob(IClient *client, const Job &job);
|
||||||
void setResult(IClient *client, const SubmitResult &result, const char *error);
|
void setResult(IClient *client, const SubmitResult &result, const char *error);
|
||||||
void setState(State state);
|
void setState(State state);
|
||||||
|
|
||||||
|
Algorithm m_algorithm;
|
||||||
bool m_tls;
|
bool m_tls;
|
||||||
char m_userId[65];
|
char m_userId[65];
|
||||||
IClient *m_proxy;
|
|
||||||
const uint64_t m_donateTime;
|
const uint64_t m_donateTime;
|
||||||
const uint64_t m_idleTime;
|
const uint64_t m_idleTime;
|
||||||
Controller *m_controller;
|
Controller *m_controller;
|
||||||
|
IClient *m_proxy;
|
||||||
IStrategy *m_strategy;
|
IStrategy *m_strategy;
|
||||||
IStrategyListener *m_listener;
|
IStrategyListener *m_listener;
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
Loading…
Reference in a new issue