mirror of
https://github.com/xmrig/xmrig.git
synced 2025-02-04 04:06:44 +00:00
Added SelfSelectClient stub.
This commit is contained in:
parent
72c45d882b
commit
e9d2e194f3
17 changed files with 209 additions and 51 deletions
|
@ -139,6 +139,7 @@ if (WITH_HTTP)
|
||||||
src/base/net/http/HttpResponse.h
|
src/base/net/http/HttpResponse.h
|
||||||
src/base/net/http/HttpServer.h
|
src/base/net/http/HttpServer.h
|
||||||
src/base/net/stratum/DaemonClient.h
|
src/base/net/stratum/DaemonClient.h
|
||||||
|
src/base/net/stratum/SelfSelectClient.h
|
||||||
src/base/net/tools/TcpServer.h
|
src/base/net/tools/TcpServer.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@ if (WITH_HTTP)
|
||||||
src/base/net/http/HttpResponse.cpp
|
src/base/net/http/HttpResponse.cpp
|
||||||
src/base/net/http/HttpServer.cpp
|
src/base/net/http/HttpServer.cpp
|
||||||
src/base/net/stratum/DaemonClient.cpp
|
src/base/net/stratum/DaemonClient.cpp
|
||||||
|
src/base/net/stratum/SelfSelectClient.cpp
|
||||||
src/base/net/tools/TcpServer.cpp
|
src/base/net/tools/TcpServer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define XMRIG_ICLIENT_H
|
#define XMRIG_ICLIENT_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define XMRIG_ICLIENTLISTENER_H
|
#define XMRIG_ICLIENTLISTENER_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
|
@ -46,6 +46,7 @@ class BaseClient : public IClient
|
||||||
public:
|
public:
|
||||||
BaseClient(int id, IClientListener *listener);
|
BaseClient(int id, IClientListener *listener);
|
||||||
|
|
||||||
|
protected:
|
||||||
inline bool isEnabled() const override { return m_enabled; }
|
inline bool isEnabled() const override { return m_enabled; }
|
||||||
inline const Job &job() const override { return m_job; }
|
inline const Job &job() const override { return m_job; }
|
||||||
inline const Pool &pool() const override { return m_pool; }
|
inline const Pool &pool() const override { return m_pool; }
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,11 @@
|
||||||
#include "base/net/stratum/SubmitResult.h"
|
#include "base/net/stratum/SubmitResult.h"
|
||||||
#include "base/net/tools/RecvBuf.h"
|
#include "base/net/tools/RecvBuf.h"
|
||||||
#include "base/net/tools/Storage.h"
|
#include "base/net/tools/Storage.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
#include "crypto/common/Algorithm.h"
|
#include "crypto/common/Algorithm.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct bio_st BIO;
|
using BIO = struct bio_st;
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -56,6 +57,8 @@ class JobResult;
|
||||||
class Client : public BaseClient, public IDnsListener, public ILineListener
|
class Client : public BaseClient, public IDnsListener, public ILineListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client)
|
||||||
|
|
||||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,10 @@
|
||||||
#define XMRIG_DAEMONCLIENT_H
|
#define XMRIG_DAEMONCLIENT_H
|
||||||
|
|
||||||
|
|
||||||
#include "base/net/stratum/BaseClient.h"
|
|
||||||
#include "base/kernel/interfaces/ITimerListener.h"
|
|
||||||
#include "base/kernel/interfaces/IHttpListener.h"
|
#include "base/kernel/interfaces/IHttpListener.h"
|
||||||
|
#include "base/kernel/interfaces/ITimerListener.h"
|
||||||
|
#include "base/net/stratum/BaseClient.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -38,6 +39,8 @@ namespace xmrig {
|
||||||
class DaemonClient : public BaseClient, public ITimerListener, public IHttpListener
|
class DaemonClient : public BaseClient, public ITimerListener, public IHttpListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(DaemonClient)
|
||||||
|
|
||||||
DaemonClient(int id, IClientListener *listener);
|
DaemonClient(int id, IClientListener *listener);
|
||||||
~DaemonClient() override;
|
~DaemonClient() override;
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,17 @@
|
||||||
#include "base/net/stratum/Pool.h"
|
#include "base/net/stratum/Pool.h"
|
||||||
#include "base/io/json/Json.h"
|
#include "base/io/json/Json.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
#include "base/kernel/Platform.h"
|
||||||
|
#include "base/net/stratum/Client.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_HTTP
|
||||||
|
# include "base/net/stratum/DaemonClient.h"
|
||||||
|
# include "base/net/stratum/SelfSelectClient.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
static const char *kAlgo = "algo";
|
static const char *kAlgo = "algo";
|
||||||
|
@ -128,7 +136,13 @@ bool xmrig::Pool::isEnabled() const
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_FEATURE_HTTP
|
# ifndef XMRIG_FEATURE_HTTP
|
||||||
if (isDaemon()) {
|
if (m_mode == MODE_DAEMON) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef XMRIG_FEATURE_HTTP
|
||||||
|
if (m_mode == MODE_SELF_SELECT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
@ -158,6 +172,32 @@ bool xmrig::Pool::isEqual(const Pool &other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) const
|
||||||
|
{
|
||||||
|
IClient *client = nullptr;
|
||||||
|
|
||||||
|
if (m_mode == MODE_POOL) {
|
||||||
|
client = new Client(id, Platform::userAgent(), listener);
|
||||||
|
}
|
||||||
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
|
else if (m_mode == MODE_DAEMON) {
|
||||||
|
client = new DaemonClient(id, listener);
|
||||||
|
}
|
||||||
|
else if (m_mode == MODE_SELF_SELECT) {
|
||||||
|
client = new SelfSelectClient(id, Platform::userAgent(), listener);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
assert(client != nullptr);
|
||||||
|
|
||||||
|
if (client) {
|
||||||
|
client->setPool(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const
|
rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const
|
||||||
{
|
{
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class IClient;
|
||||||
|
class IClientListener;
|
||||||
|
|
||||||
|
|
||||||
class Pool
|
class Pool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -67,7 +71,6 @@ public:
|
||||||
bool tls = false
|
bool tls = false
|
||||||
);
|
);
|
||||||
|
|
||||||
inline bool isDaemon() const { return m_mode == MODE_DAEMON; }
|
|
||||||
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
|
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
|
||||||
inline bool isTLS() const { return m_flags.test(FLAG_TLS); }
|
inline bool isTLS() const { return m_flags.test(FLAG_TLS); }
|
||||||
inline bool isValid() const { return m_url.isValid(); }
|
inline bool isValid() const { return m_url.isValid(); }
|
||||||
|
@ -94,6 +97,7 @@ public:
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
bool isEqual(const Pool &other) const;
|
bool isEqual(const Pool &other) const;
|
||||||
|
IClient *createClient(int id, IClientListener *listener) const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
std::string printableName() const;
|
std::string printableName() const;
|
||||||
|
|
||||||
|
|
40
src/base/net/stratum/SelfSelectClient.cpp
Normal file
40
src/base/net/stratum/SelfSelectClient.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/SelfSelectClient.h"
|
||||||
|
#include "base/net/stratum/Client.h"
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener) :
|
||||||
|
m_listener(listener)
|
||||||
|
{
|
||||||
|
m_client = new Client(id, agent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::SelfSelectClient::~SelfSelectClient()
|
||||||
|
{
|
||||||
|
delete m_client;
|
||||||
|
}
|
87
src/base/net/stratum/SelfSelectClient.h
Normal file
87
src/base/net/stratum/SelfSelectClient.h
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_SELFSELECTCLIENT_H
|
||||||
|
#define XMRIG_SELFSELECTCLIENT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
#include "base/kernel/interfaces/IClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class SelfSelectClient : public IClient, public IClientListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(SelfSelectClient)
|
||||||
|
|
||||||
|
SelfSelectClient(int id, const char *agent, IClientListener *listener);
|
||||||
|
~SelfSelectClient() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// IClient
|
||||||
|
bool disconnect() override { return m_client->disconnect(); }
|
||||||
|
bool hasExtension(Extension extension) const noexcept override { return m_client->hasExtension(extension); }
|
||||||
|
bool isEnabled() const override { return m_client->isEnabled(); }
|
||||||
|
bool isTLS() const override { return m_client->isTLS(); }
|
||||||
|
const char *mode() const override { return m_client->mode(); }
|
||||||
|
const char *tlsFingerprint() const override { return m_client->tlsFingerprint(); }
|
||||||
|
const char *tlsVersion() const override { return m_client->tlsVersion(); }
|
||||||
|
const Job &job() const override { return m_client->job(); }
|
||||||
|
const Pool &pool() const override { return m_client->pool(); }
|
||||||
|
const String &ip() const override { return m_client->ip(); }
|
||||||
|
int id() const override { return m_client->id(); }
|
||||||
|
int64_t submit(const JobResult &result) override { return m_client->submit(result); }
|
||||||
|
void connect() override { m_client->connect(); }
|
||||||
|
void connect(const Pool &pool) override { m_client->connect(pool); }
|
||||||
|
void deleteLater() override { m_client->deleteLater(); }
|
||||||
|
void setAlgo(const Algorithm &algo) override { m_client->setAlgo(algo); }
|
||||||
|
void setEnabled(bool enabled) override { m_client->setEnabled(enabled); }
|
||||||
|
void setPool(const Pool &pool) override { m_client->setPool(pool); }
|
||||||
|
void setQuiet(bool quiet) override { m_client->setQuiet(quiet); }
|
||||||
|
void setRetries(int retries) override { m_client->setRetries(retries); }
|
||||||
|
void setRetryPause(uint64_t ms) override { m_client->setRetryPause(ms); }
|
||||||
|
void tick(uint64_t now) override { m_client->tick(now); }
|
||||||
|
|
||||||
|
// IClientListener
|
||||||
|
void onClose(IClient *, int failures) override { m_listener->onClose(this, failures); }
|
||||||
|
void onJobReceived(IClient *, const Job &job, const rapidjson::Value ¶ms) override { m_listener->onJobReceived(this, job, params); }
|
||||||
|
void onLogin(IClient *, rapidjson::Document &doc, rapidjson::Value ¶ms) override { m_listener->onLogin(this, doc, params); }
|
||||||
|
void onLoginSuccess(IClient *) override { m_listener->onLoginSuccess(this); }
|
||||||
|
void onResultAccepted(IClient *, const SubmitResult &result, const char *error) override { m_listener->onResultAccepted(this, result, error); }
|
||||||
|
void onVerifyAlgorithm(const IClient *, const Algorithm &algorithm, bool *ok) override { m_listener->onVerifyAlgorithm(this, algorithm, ok); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
IClient *m_client;
|
||||||
|
IClientListener *m_listener;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_SELFSELECTCLIENT_H */
|
|
@ -23,15 +23,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/strategies/FailoverStrategy.h"
|
||||||
|
#include "base/kernel/interfaces/IClient.h"
|
||||||
#include "base/kernel/interfaces/IStrategyListener.h"
|
#include "base/kernel/interfaces/IStrategyListener.h"
|
||||||
#include "base/kernel/Platform.h"
|
#include "base/kernel/Platform.h"
|
||||||
#include "base/net/stratum/Client.h"
|
|
||||||
#include "base/net/stratum/strategies/FailoverStrategy.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HTTP
|
|
||||||
# include "base/net/stratum/DaemonClient.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||||
|
@ -69,16 +64,8 @@ xmrig::FailoverStrategy::~FailoverStrategy()
|
||||||
|
|
||||||
void xmrig::FailoverStrategy::add(const Pool &pool)
|
void xmrig::FailoverStrategy::add(const Pool &pool)
|
||||||
{
|
{
|
||||||
const int id = static_cast<int>(m_pools.size());
|
IClient *client = pool.createClient(static_cast<int>(m_pools.size()), this);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
|
||||||
IClient *client = !pool.isDaemon() ? static_cast<IClient *>(new Client(id, Platform::userAgent(), this))
|
|
||||||
: static_cast<IClient *>(new DaemonClient(id, this));
|
|
||||||
# else
|
|
||||||
IClient *client = new Client(id, Platform::userAgent(), this);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
client->setPool(pool);
|
|
||||||
client->setRetries(m_retries);
|
client->setRetries(m_retries);
|
||||||
client->setRetryPause(m_retryPause * 1000);
|
client->setRetryPause(m_retryPause * 1000);
|
||||||
client->setQuiet(m_quiet);
|
client->setQuiet(m_quiet);
|
||||||
|
@ -123,8 +110,8 @@ void xmrig::FailoverStrategy::setAlgo(const Algorithm &algo)
|
||||||
|
|
||||||
void xmrig::FailoverStrategy::stop()
|
void xmrig::FailoverStrategy::stop()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_pools.size(); ++i) {
|
for (auto &pool : m_pools) {
|
||||||
m_pools[i]->disconnect();
|
pool->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_index = 0;
|
m_index = 0;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
#include "base/kernel/interfaces/IStrategy.h"
|
#include "base/kernel/interfaces/IStrategy.h"
|
||||||
#include "base/net/stratum/Pool.h"
|
#include "base/net/stratum/Pool.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -44,6 +45,8 @@ class IStrategyListener;
|
||||||
class FailoverStrategy : public IStrategy, public IClientListener
|
class FailoverStrategy : public IStrategy, public IClientListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(FailoverStrategy)
|
||||||
|
|
||||||
FailoverStrategy(const std::vector<Pool> &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
FailoverStrategy(const std::vector<Pool> &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
||||||
FailoverStrategy(int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
FailoverStrategy(int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
||||||
~FailoverStrategy() override;
|
~FailoverStrategy() override;
|
||||||
|
|
|
@ -23,33 +23,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
|
||||||
|
#include "base/kernel/interfaces/IClient.h"
|
||||||
#include "base/kernel/interfaces/IStrategyListener.h"
|
#include "base/kernel/interfaces/IStrategyListener.h"
|
||||||
#include "base/kernel/Platform.h"
|
#include "base/kernel/Platform.h"
|
||||||
#include "base/net/stratum/Client.h"
|
#include "base/net/stratum/Pool.h"
|
||||||
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HTTP
|
|
||||||
# include "base/net/stratum/DaemonClient.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
xmrig::SinglePoolStrategy::SinglePoolStrategy(const Pool &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
xmrig::SinglePoolStrategy::SinglePoolStrategy(const Pool &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||||
m_active(false),
|
m_active(false),
|
||||||
m_listener(listener)
|
m_listener(listener)
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
m_client = pool.createClient(0, this);
|
||||||
if (!pool.isDaemon()) {
|
|
||||||
m_client = new Client(0, Platform::userAgent(), this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_client = new DaemonClient(0, this);
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
m_client = new Client(0, Platform::userAgent(), this);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
m_client->setPool(pool);
|
|
||||||
m_client->setRetries(retries);
|
m_client->setRetries(retries);
|
||||||
m_client->setRetryPause(retryPause * 1000);
|
m_client->setRetryPause(retryPause * 1000);
|
||||||
m_client->setQuiet(quiet);
|
m_client->setQuiet(quiet);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
#include "base/kernel/interfaces/IStrategy.h"
|
#include "base/kernel/interfaces/IStrategy.h"
|
||||||
|
#include "base/tools/Object.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -41,6 +42,8 @@ class Pool;
|
||||||
class SinglePoolStrategy : public IStrategy, public IClientListener
|
class SinglePoolStrategy : public IStrategy, public IClientListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(SinglePoolStrategy)
|
||||||
|
|
||||||
SinglePoolStrategy(const Pool &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
SinglePoolStrategy(const Pool &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
|
||||||
~SinglePoolStrategy() override;
|
~SinglePoolStrategy() override;
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ void xmrig::DonateStrategy::onTimer(const Timer *)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::Client *xmrig::DonateStrategy::createProxy()
|
xmrig::IClient *xmrig::DonateStrategy::createProxy()
|
||||||
{
|
{
|
||||||
if (m_controller->config()->pools().proxyDonate() == Pools::PROXY_DONATE_NONE) {
|
if (m_controller->config()->pools().proxyDonate() == Pools::PROXY_DONATE_NONE) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -251,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 pool(client->ip(), client->pool().port(), m_userId, client->pool().password(), 0, true, client->isTLS());
|
||||||
pool.setAlgo(client->pool().algorithm());
|
pool.setAlgo(client->pool().algorithm());
|
||||||
|
|
||||||
auto proxy = new Client(-1, Platform::userAgent(), this);
|
IClient *proxy = new Client(-1, Platform::userAgent(), this);
|
||||||
proxy->setPool(pool);
|
proxy->setPool(pool);
|
||||||
proxy->setQuiet(true);
|
proxy->setQuiet(true);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ private:
|
||||||
|
|
||||||
inline State state() const { return m_state; }
|
inline State state() const { return m_state; }
|
||||||
|
|
||||||
Client *createProxy();
|
IClient *createProxy();
|
||||||
void idle(double min, double max);
|
void idle(double min, double max);
|
||||||
void setAlgorithms(rapidjson::Document &doc, rapidjson::Value ¶ms);
|
void setAlgorithms(rapidjson::Document &doc, rapidjson::Value ¶ms);
|
||||||
void setJob(IClient *client, const Job &job);
|
void setJob(IClient *client, const Job &job);
|
||||||
|
|
Loading…
Reference in a new issue