#1202 Fixed algorithm verification in donate strategy.
This commit is contained in:
@ -97,7 +97,7 @@ public:
|
||||
bool isEnabled(const Algorithm &algorithm) const
|
||||
{
|
||||
for (IBackend *backend : backends) {
|
||||
if (backend->isEnabled(algorithm)) {
|
||||
if (backend->isEnabled() && backend->isEnabled(algorithm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <inttypes.h>
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
@ -83,11 +83,7 @@ xmrig::Network::~Network()
|
||||
JobResults::stop();
|
||||
|
||||
delete m_timer;
|
||||
|
||||
if (m_donate) {
|
||||
delete m_donate;
|
||||
}
|
||||
|
||||
delete m_donate;
|
||||
delete m_strategy;
|
||||
}
|
||||
|
||||
@ -304,8 +300,8 @@ void xmrig::Network::getResults(rapidjson::Value &reply, rapidjson::Document &do
|
||||
results.AddMember("hashes_total", m_state.total, allocator);
|
||||
|
||||
Value best(kArrayType);
|
||||
for (size_t i = 0; i < m_state.topDiff.size(); ++i) {
|
||||
best.PushBack(m_state.topDiff[i], allocator);
|
||||
for (uint64_t i : m_state.topDiff) {
|
||||
best.PushBack(i, allocator);
|
||||
}
|
||||
|
||||
results.AddMember("best", best, allocator);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/kernel/interfaces/IStrategyListener.h"
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "interfaces/IJobResultListener.h"
|
||||
#include "net/NetworkState.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
@ -49,6 +50,8 @@ class IStrategy;
|
||||
class Network : public IJobResultListener, public IStrategyListener, public IBaseListener, public ITimerListener, public IApiListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Network)
|
||||
|
||||
Network(Controller *controller);
|
||||
~Network() override;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
@ -58,17 +58,10 @@ static const char *kDonateHostTls = "donate.ssl.xmrig.com";
|
||||
|
||||
|
||||
xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener *listener) :
|
||||
m_tls(false),
|
||||
m_userId(),
|
||||
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_controller(controller),
|
||||
m_proxy(nullptr),
|
||||
m_strategy(nullptr),
|
||||
m_listener(listener),
|
||||
m_state(STATE_NEW),
|
||||
m_now(0),
|
||||
m_timestamp(0)
|
||||
m_listener(listener)
|
||||
{
|
||||
uint8_t hash[200];
|
||||
|
||||
@ -77,15 +70,15 @@ xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener
|
||||
Buffer::toHex(hash, 32, m_userId);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
m_pools.push_back(Pool(kDonateHostTls, 443, m_userId, nullptr, 0, true, true));
|
||||
m_pools.emplace_back(kDonateHostTls, 443, m_userId, nullptr, 0, true, true);
|
||||
# endif
|
||||
m_pools.push_back(Pool(kDonateHost, 3333, m_userId, nullptr, 0, true));
|
||||
m_pools.emplace_back(kDonateHost, 3333, m_userId, nullptr, 0, true);
|
||||
|
||||
if (m_pools.size() > 1) {
|
||||
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
|
||||
m_strategy = new FailoverStrategy(m_pools, 10, 2, this, true);
|
||||
}
|
||||
else {
|
||||
m_strategy = new SinglePoolStrategy(m_pools.front(), 1, 2, this, true);
|
||||
m_strategy = new SinglePoolStrategy(m_pools.front(), 10, 2, this, true);
|
||||
}
|
||||
|
||||
m_timer = new Timer(this);
|
||||
@ -223,6 +216,18 @@ void xmrig::DonateStrategy::onLoginSuccess(IClient *client)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DonateStrategy::onVerifyAlgorithm(const IClient *client, const Algorithm &algorithm, bool *ok)
|
||||
{
|
||||
m_listener->onVerifyAlgorithm(this, client, algorithm, ok);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DonateStrategy::onVerifyAlgorithm(IStrategy *, const IClient *client, const Algorithm &algorithm, bool *ok)
|
||||
{
|
||||
m_listener->onVerifyAlgorithm(this, client, algorithm, ok);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DonateStrategy::onTimer(const Timer *)
|
||||
{
|
||||
setState(isActive() ? STATE_WAIT : STATE_CONNECT);
|
||||
@ -246,7 +251,7 @@ xmrig::Client *xmrig::DonateStrategy::createProxy()
|
||||
Pool pool(client->ip(), client->pool().port(), m_userId, client->pool().password(), 0, true, client->isTLS());
|
||||
pool.setAlgo(client->pool().algorithm());
|
||||
|
||||
Client *proxy = new Client(-1, Platform::userAgent(), this);
|
||||
auto proxy = new Client(-1, Platform::userAgent(), this);
|
||||
proxy->setPool(pool);
|
||||
proxy->setQuiet(true);
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "base/kernel/interfaces/IStrategyListener.h"
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@ -47,6 +48,8 @@ class IStrategyListener;
|
||||
class DonateStrategy : public IStrategy, public IStrategyListener, public ITimerListener, public IClientListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(DonateStrategy)
|
||||
|
||||
DonateStrategy(Controller *controller, IStrategyListener *listener);
|
||||
~DonateStrategy() override;
|
||||
|
||||
@ -57,8 +60,6 @@ protected:
|
||||
inline void onJobReceived(IClient *client, const Job &job, const rapidjson::Value &) override { setJob(client, job); }
|
||||
inline void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override { setResult(client, result, error); }
|
||||
inline void onResultAccepted(IStrategy *, IClient *client, const SubmitResult &result, const char *error) override { setResult(client, result, error); }
|
||||
inline void onVerifyAlgorithm(const IClient *, const Algorithm &, bool *) override {}
|
||||
inline void onVerifyAlgorithm(IStrategy *, const IClient *, const Algorithm &, bool *) override {}
|
||||
inline void resume() override {}
|
||||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
@ -74,6 +75,8 @@ protected:
|
||||
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 onVerifyAlgorithm(const IClient *client, const Algorithm &algorithm, bool *ok) override;
|
||||
void onVerifyAlgorithm(IStrategy *strategy, const IClient *client, const Algorithm &algorithm, bool *ok) override;
|
||||
|
||||
void onTimer(const Timer *timer) override;
|
||||
|
||||
@ -96,19 +99,19 @@ private:
|
||||
void setState(State state);
|
||||
|
||||
Algorithm m_algorithm;
|
||||
bool m_tls;
|
||||
char m_userId[65];
|
||||
bool m_tls = false;
|
||||
char m_userId[65] = { 0 };
|
||||
const uint64_t m_donateTime;
|
||||
const uint64_t m_idleTime;
|
||||
Controller *m_controller;
|
||||
IClient *m_proxy;
|
||||
IStrategy *m_strategy;
|
||||
IClient *m_proxy = nullptr;
|
||||
IStrategy *m_strategy = nullptr;
|
||||
IStrategyListener *m_listener;
|
||||
State m_state;
|
||||
State m_state = STATE_NEW;
|
||||
std::vector<Pool> m_pools;
|
||||
Timer *m_timer;
|
||||
uint64_t m_now;
|
||||
uint64_t m_timestamp;
|
||||
Timer *m_timer = nullptr;
|
||||
uint64_t m_now = 0;
|
||||
uint64_t m_timestamp = 0;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user