Move network classes into xmrig namespace.
This commit is contained in:
parent
dbdcc14672
commit
ee667144e8
42 changed files with 481 additions and 332 deletions
|
@ -425,6 +425,12 @@ bool xmrig::CommonConfig::parseUint64(int key, uint64_t arg)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::CommonConfig::parseJSON(const rapidjson::Document &doc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CommonConfig::setFileName(const char *fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
|
@ -480,7 +486,7 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
|||
}
|
||||
|
||||
|
||||
Pool &xmrig::CommonConfig::currentPool()
|
||||
xmrig::Pool &xmrig::CommonConfig::currentPool()
|
||||
{
|
||||
fixup();
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ protected:
|
|||
bool parseBoolean(int key, bool enable) override;
|
||||
bool parseString(int key, const char *arg) override;
|
||||
bool parseUint64(int key, uint64_t arg) override;
|
||||
void parseJSON(const rapidjson::Document &doc) override;
|
||||
void setFileName(const char *fileName) override;
|
||||
|
||||
Algorithm m_algorithm;
|
||||
|
@ -101,12 +102,12 @@ protected:
|
|||
State m_state;
|
||||
std::vector<Pool> m_activePools;
|
||||
std::vector<Pool> m_pools;
|
||||
xmrig::String m_apiId;
|
||||
xmrig::String m_apiToken;
|
||||
xmrig::String m_apiWorkerId;
|
||||
xmrig::String m_fileName;
|
||||
xmrig::String m_logFile;
|
||||
xmrig::String m_userAgent;
|
||||
String m_apiId;
|
||||
String m_apiToken;
|
||||
String m_apiWorkerId;
|
||||
String m_fileName;
|
||||
String m_logFile;
|
||||
String m_userAgent;
|
||||
|
||||
private:
|
||||
bool parseInt(int key, int arg);
|
||||
|
|
|
@ -6,7 +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 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* 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
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.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
|
||||
|
@ -21,22 +22,27 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ICLIENTLISTENER_H__
|
||||
#define __ICLIENTLISTENER_H__
|
||||
#ifndef XMRIG_ICLIENTLISTENER_H
|
||||
#define XMRIG_ICLIENTLISTENER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
class Client;
|
||||
class Job;
|
||||
class SubmitResult;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client;
|
||||
|
||||
|
||||
class IClientListener
|
||||
{
|
||||
public:
|
||||
virtual ~IClientListener() {}
|
||||
virtual ~IClientListener() = default;
|
||||
|
||||
virtual void onClose(Client *client, int failures) = 0;
|
||||
virtual void onJobReceived(Client *client, const Job &job) = 0;
|
||||
|
@ -45,4 +51,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif // __ICLIENTLISTENER_H__
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ICLIENTLISTENER_H
|
||||
|
|
|
@ -33,23 +33,27 @@ class JobResult;
|
|||
|
||||
|
||||
namespace xmrig {
|
||||
class Algorithm;
|
||||
}
|
||||
|
||||
|
||||
class Algorithm;
|
||||
|
||||
|
||||
class IStrategy
|
||||
{
|
||||
public:
|
||||
virtual ~IStrategy() {}
|
||||
virtual ~IStrategy() = default;
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
virtual int64_t submit(const JobResult &result) = 0;
|
||||
virtual void connect() = 0;
|
||||
virtual void resume() = 0;
|
||||
virtual void setAlgo(const xmrig::Algorithm &algo) = 0;
|
||||
virtual void setAlgo(const Algorithm &algo) = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void tick(uint64_t now) = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ISTRATEGY_H
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -21,13 +22,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ISTRATEGYLISTENER_H__
|
||||
#define __ISTRATEGYLISTENER_H__
|
||||
#ifndef XMRIG_ISTRATEGYLISTENER_H
|
||||
#define XMRIG_ISTRATEGYLISTENER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client;
|
||||
class IStrategy;
|
||||
class Job;
|
||||
|
@ -37,7 +41,7 @@ class SubmitResult;
|
|||
class IStrategyListener
|
||||
{
|
||||
public:
|
||||
virtual ~IStrategyListener() {}
|
||||
virtual ~IStrategyListener() = default;
|
||||
|
||||
virtual void onActive(IStrategy *strategy, Client *client) = 0;
|
||||
virtual void onJob(IStrategy *strategy, Client *client, const Job &job) = 0;
|
||||
|
@ -46,4 +50,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif // __ISTRATEGYLISTENER_H__
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ISTRATEGYLISTENER_H
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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
|
||||
|
@ -51,8 +52,12 @@
|
|||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
int64_t Client::m_sequence = 1;
|
||||
xmrig::Storage<Client> Client::m_storage;
|
||||
Storage<Client> Client::m_storage;
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
|
@ -66,7 +71,7 @@ static const char *states[] = {
|
|||
#endif
|
||||
|
||||
|
||||
Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
m_ipv6(false),
|
||||
m_nicehash(false),
|
||||
m_quiet(false),
|
||||
|
@ -103,13 +108,13 @@ Client::Client(int id, const char *agent, IClientListener *listener) :
|
|||
}
|
||||
|
||||
|
||||
Client::~Client()
|
||||
xmrig::Client::~Client()
|
||||
{
|
||||
delete m_socket;
|
||||
}
|
||||
|
||||
|
||||
void Client::connect()
|
||||
void xmrig::Client::connect()
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
if (m_pool.isTLS()) {
|
||||
|
@ -126,14 +131,14 @@ void Client::connect()
|
|||
*
|
||||
* @param url
|
||||
*/
|
||||
void Client::connect(const Pool &url)
|
||||
void xmrig::Client::connect(const Pool &url)
|
||||
{
|
||||
setPool(url);
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
void Client::deleteLater()
|
||||
void xmrig::Client::deleteLater()
|
||||
{
|
||||
if (!m_listener) {
|
||||
return;
|
||||
|
@ -148,7 +153,7 @@ void Client::deleteLater()
|
|||
|
||||
|
||||
|
||||
void Client::setPool(const Pool &pool)
|
||||
void xmrig::Client::setPool(const Pool &pool)
|
||||
{
|
||||
if (!pool.isValid()) {
|
||||
return;
|
||||
|
@ -158,7 +163,7 @@ void Client::setPool(const Pool &pool)
|
|||
}
|
||||
|
||||
|
||||
void Client::tick(uint64_t now)
|
||||
void xmrig::Client::tick(uint64_t now)
|
||||
{
|
||||
if (m_state == ConnectedState) {
|
||||
if (m_expire && now > m_expire) {
|
||||
|
@ -176,7 +181,7 @@ void Client::tick(uint64_t now)
|
|||
}
|
||||
|
||||
|
||||
bool Client::disconnect()
|
||||
bool xmrig::Client::disconnect()
|
||||
{
|
||||
m_keepAlive = 0;
|
||||
m_expire = 0;
|
||||
|
@ -186,7 +191,7 @@ bool Client::disconnect()
|
|||
}
|
||||
|
||||
|
||||
const char *Client::tlsFingerprint() const
|
||||
const char *xmrig::Client::tlsFingerprint() const
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
if (isTLS() && m_pool.fingerprint() == nullptr) {
|
||||
|
@ -198,7 +203,7 @@ const char *Client::tlsFingerprint() const
|
|||
}
|
||||
|
||||
|
||||
const char *Client::tlsVersion() const
|
||||
const char *xmrig::Client::tlsVersion() const
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
if (isTLS()) {
|
||||
|
@ -210,7 +215,7 @@ const char *Client::tlsVersion() const
|
|||
}
|
||||
|
||||
|
||||
int64_t Client::submit(const JobResult &result)
|
||||
int64_t xmrig::Client::submit(const JobResult &result)
|
||||
{
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
if (result.clientId != m_rpcId) {
|
||||
|
@ -218,7 +223,7 @@ int64_t Client::submit(const JobResult &result)
|
|||
}
|
||||
# endif
|
||||
|
||||
if (m_job.algorithm().variant() == xmrig::VARIANT_WOW && m_job.id() != result.jobId) {
|
||||
if (m_job.algorithm().variant() == VARIANT_WOW && m_job.id() != result.jobId) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -267,7 +272,7 @@ int64_t Client::submit(const JobResult &result)
|
|||
}
|
||||
|
||||
|
||||
bool Client::close()
|
||||
bool xmrig::Client::close()
|
||||
{
|
||||
if (m_state == ClosingState) {
|
||||
return m_socket != nullptr;
|
||||
|
@ -287,7 +292,7 @@ bool Client::close()
|
|||
}
|
||||
|
||||
|
||||
bool Client::isCriticalError(const char *message)
|
||||
bool xmrig::Client::isCriticalError(const char *message)
|
||||
{
|
||||
if (!message) {
|
||||
return false;
|
||||
|
@ -309,7 +314,7 @@ bool Client::isCriticalError(const char *message)
|
|||
}
|
||||
|
||||
|
||||
bool Client::isTLS() const
|
||||
bool xmrig::Client::isTLS() const
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
return m_pool.isTLS() && m_tls;
|
||||
|
@ -319,7 +324,7 @@ bool Client::isTLS() const
|
|||
}
|
||||
|
||||
|
||||
bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
{
|
||||
if (!params.IsObject()) {
|
||||
*code = 2;
|
||||
|
@ -394,7 +399,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
}
|
||||
|
||||
|
||||
bool Client::parseLogin(const rapidjson::Value &result, int *code)
|
||||
bool xmrig::Client::parseLogin(const rapidjson::Value &result, int *code)
|
||||
{
|
||||
if (!m_rpcId.setId(result["id"].GetString())) {
|
||||
*code = 1;
|
||||
|
@ -414,7 +419,7 @@ bool Client::parseLogin(const rapidjson::Value &result, int *code)
|
|||
}
|
||||
|
||||
|
||||
bool Client::send(BIO *bio)
|
||||
bool xmrig::Client::send(BIO *bio)
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
uv_buf_t buf;
|
||||
|
@ -447,10 +452,10 @@ bool Client::send(BIO *bio)
|
|||
}
|
||||
|
||||
|
||||
bool Client::verifyAlgorithm(const xmrig::Algorithm &algorithm) const
|
||||
bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm) const
|
||||
{
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
if (m_pool.algorithm().variant() == xmrig::VARIANT_AUTO || m_id == -1) {
|
||||
if (m_pool.algorithm().variant() == VARIANT_AUTO || m_id == -1) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
@ -474,7 +479,7 @@ bool Client::verifyAlgorithm(const xmrig::Algorithm &algorithm) const
|
|||
}
|
||||
|
||||
|
||||
int Client::resolve(const char *host)
|
||||
int xmrig::Client::resolve(const char *host)
|
||||
{
|
||||
setState(HostLookupState);
|
||||
|
||||
|
@ -497,7 +502,7 @@ int Client::resolve(const char *host)
|
|||
}
|
||||
|
||||
|
||||
int64_t Client::send(const rapidjson::Document &doc)
|
||||
int64_t xmrig::Client::send(const rapidjson::Document &doc)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
|
@ -520,7 +525,7 @@ int64_t Client::send(const rapidjson::Document &doc)
|
|||
}
|
||||
|
||||
|
||||
int64_t Client::send(size_t size)
|
||||
int64_t xmrig::Client::send(size_t size)
|
||||
{
|
||||
LOG_DEBUG("[%s] send (%d bytes): \"%s\"", m_pool.url(), size, m_sendBuf);
|
||||
|
||||
|
@ -551,7 +556,7 @@ int64_t Client::send(size_t size)
|
|||
}
|
||||
|
||||
|
||||
void Client::connect(const std::vector<addrinfo*> &ipv4, const std::vector<addrinfo*> &ipv6)
|
||||
void xmrig::Client::connect(const std::vector<addrinfo*> &ipv4, const std::vector<addrinfo*> &ipv6)
|
||||
{
|
||||
addrinfo *addr = nullptr;
|
||||
m_ipv6 = ipv4.empty() && !ipv6.empty();
|
||||
|
@ -569,7 +574,7 @@ void Client::connect(const std::vector<addrinfo*> &ipv4, const std::vector<addri
|
|||
}
|
||||
|
||||
|
||||
void Client::connect(sockaddr *addr)
|
||||
void xmrig::Client::connect(sockaddr *addr)
|
||||
{
|
||||
setState(ConnectingState);
|
||||
|
||||
|
@ -592,7 +597,7 @@ void Client::connect(sockaddr *addr)
|
|||
}
|
||||
|
||||
|
||||
void Client::handshake()
|
||||
void xmrig::Client::handshake()
|
||||
{
|
||||
# ifndef XMRIG_NO_TLS
|
||||
if (isTLS()) {
|
||||
|
@ -608,7 +613,7 @@ void Client::handshake()
|
|||
}
|
||||
|
||||
|
||||
void Client::login()
|
||||
void xmrig::Client::login()
|
||||
{
|
||||
using namespace rapidjson;
|
||||
m_results.clear();
|
||||
|
@ -648,7 +653,7 @@ void Client::login()
|
|||
}
|
||||
|
||||
|
||||
void Client::onClose()
|
||||
void xmrig::Client::onClose()
|
||||
{
|
||||
delete m_socket;
|
||||
|
||||
|
@ -667,7 +672,7 @@ void Client::onClose()
|
|||
}
|
||||
|
||||
|
||||
void Client::parse(char *line, size_t len)
|
||||
void xmrig::Client::parse(char *line, size_t len)
|
||||
{
|
||||
startTimeout();
|
||||
|
||||
|
@ -706,7 +711,7 @@ void Client::parse(char *line, size_t len)
|
|||
}
|
||||
|
||||
|
||||
void Client::parseExtensions(const rapidjson::Value &value)
|
||||
void xmrig::Client::parseExtensions(const rapidjson::Value &value)
|
||||
{
|
||||
m_extensions = 0;
|
||||
|
||||
|
@ -733,7 +738,7 @@ void Client::parseExtensions(const rapidjson::Value &value)
|
|||
}
|
||||
|
||||
|
||||
void Client::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error)
|
||||
void xmrig::Client::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error)
|
||||
{
|
||||
if (error.IsObject()) {
|
||||
if (!isQuiet()) {
|
||||
|
@ -759,7 +764,7 @@ void Client::parseNotification(const char *method, const rapidjson::Value ¶m
|
|||
}
|
||||
|
||||
|
||||
void Client::parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||
void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||
{
|
||||
if (error.IsObject()) {
|
||||
const char *message = error["message"].GetString();
|
||||
|
@ -811,13 +816,13 @@ void Client::parseResponse(int64_t id, const rapidjson::Value &result, const rap
|
|||
}
|
||||
|
||||
|
||||
void Client::ping()
|
||||
void xmrig::Client::ping()
|
||||
{
|
||||
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
||||
}
|
||||
|
||||
|
||||
void Client::read()
|
||||
void xmrig::Client::read()
|
||||
{
|
||||
char* end;
|
||||
char* start = m_recvBuf.base;
|
||||
|
@ -846,7 +851,7 @@ void Client::read()
|
|||
}
|
||||
|
||||
|
||||
void Client::reconnect()
|
||||
void xmrig::Client::reconnect()
|
||||
{
|
||||
if (!m_listener) {
|
||||
m_storage.remove(m_key);
|
||||
|
@ -869,7 +874,7 @@ void Client::reconnect()
|
|||
}
|
||||
|
||||
|
||||
void Client::setState(SocketState state)
|
||||
void xmrig::Client::setState(SocketState state)
|
||||
{
|
||||
LOG_DEBUG("[%s] state: \"%s\"", m_pool.url(), states[state]);
|
||||
|
||||
|
@ -881,7 +886,7 @@ void Client::setState(SocketState state)
|
|||
}
|
||||
|
||||
|
||||
void Client::startTimeout()
|
||||
void xmrig::Client::startTimeout()
|
||||
{
|
||||
m_expire = 0;
|
||||
|
||||
|
@ -891,7 +896,7 @@ void Client::startTimeout()
|
|||
}
|
||||
|
||||
|
||||
void Client::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
|
||||
void xmrig::Client::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
|
||||
{
|
||||
auto client = getClient(handle->data);
|
||||
if (!client) {
|
||||
|
@ -903,7 +908,7 @@ void Client::onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t
|
|||
}
|
||||
|
||||
|
||||
void Client::onClose(uv_handle_t *handle)
|
||||
void xmrig::Client::onClose(uv_handle_t *handle)
|
||||
{
|
||||
auto client = getClient(handle->data);
|
||||
if (!client) {
|
||||
|
@ -914,7 +919,7 @@ void Client::onClose(uv_handle_t *handle)
|
|||
}
|
||||
|
||||
|
||||
void Client::onConnect(uv_connect_t *req, int status)
|
||||
void xmrig::Client::onConnect(uv_connect_t *req, int status)
|
||||
{
|
||||
auto client = getClient(req->data);
|
||||
if (!client) {
|
||||
|
@ -943,7 +948,7 @@ void Client::onConnect(uv_connect_t *req, int status)
|
|||
}
|
||||
|
||||
|
||||
void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||
void xmrig::Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
auto client = getClient(stream->data);
|
||||
if (!client) {
|
||||
|
@ -986,7 +991,7 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
|||
}
|
||||
|
||||
|
||||
void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
|
||||
void xmrig::Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
|
||||
{
|
||||
auto client = getClient(req->data);
|
||||
if (!client) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 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
|
||||
|
@ -39,13 +40,16 @@
|
|||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IClientListener;
|
||||
class JobResult;
|
||||
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
|
@ -85,7 +89,7 @@ public:
|
|||
inline int id() const { return m_id; }
|
||||
inline SocketState state() const { return m_state; }
|
||||
inline uint16_t port() const { return m_pool.port(); }
|
||||
inline void setAlgo(const xmrig::Algorithm &algo) { m_pool.setAlgo(algo); }
|
||||
inline void setAlgo(const Algorithm &algo) { m_pool.setAlgo(algo); }
|
||||
inline void setQuiet(bool quiet) { m_quiet = quiet; }
|
||||
inline void setRetries(int retries) { m_retries = retries; }
|
||||
inline void setRetryPause(int ms) { m_retryPause = ms; }
|
||||
|
@ -105,7 +109,7 @@ private:
|
|||
bool parseJob(const rapidjson::Value ¶ms, int *code);
|
||||
bool parseLogin(const rapidjson::Value &result, int *code);
|
||||
bool send(BIO *bio);
|
||||
bool verifyAlgorithm(const xmrig::Algorithm &algorithm) const;
|
||||
bool verifyAlgorithm(const Algorithm &algorithm) const;
|
||||
int resolve(const char *host);
|
||||
int64_t send(const rapidjson::Document &doc);
|
||||
int64_t send(size_t size);
|
||||
|
@ -162,11 +166,14 @@ private:
|
|||
uv_getaddrinfo_t m_resolver;
|
||||
uv_stream_t *m_stream;
|
||||
uv_tcp_t *m_socket;
|
||||
xmrig::Id m_rpcId;
|
||||
Id m_rpcId;
|
||||
|
||||
static int64_t m_sequence;
|
||||
static xmrig::Storage<Client> m_storage;
|
||||
static Storage<Client> m_storage;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_CLIENT_H */
|
||||
|
|
|
@ -58,7 +58,7 @@ char hf_bin2hex(unsigned char c)
|
|||
}
|
||||
|
||||
|
||||
Job::Job() :
|
||||
xmrig::Job::Job() :
|
||||
m_autoVariant(false),
|
||||
m_nicehash(false),
|
||||
m_poolId(-2),
|
||||
|
@ -72,8 +72,8 @@ Job::Job() :
|
|||
}
|
||||
|
||||
|
||||
Job::Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmrig::Id &clientId) :
|
||||
m_autoVariant(algorithm.variant() == xmrig::VARIANT_AUTO),
|
||||
xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Id &clientId) :
|
||||
m_autoVariant(algorithm.variant() == VARIANT_AUTO),
|
||||
m_nicehash(nicehash),
|
||||
m_poolId(poolId),
|
||||
m_threadId(-1),
|
||||
|
@ -88,18 +88,18 @@ Job::Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmr
|
|||
}
|
||||
|
||||
|
||||
Job::~Job()
|
||||
xmrig::Job::~Job()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool Job::isEqual(const Job &other) const
|
||||
bool xmrig::Job::isEqual(const Job &other) const
|
||||
{
|
||||
return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool Job::setBlob(const char *blob)
|
||||
bool xmrig::Job::setBlob(const char *blob)
|
||||
{
|
||||
if (!blob) {
|
||||
return false;
|
||||
|
@ -128,14 +128,14 @@ bool Job::setBlob(const char *blob)
|
|||
}
|
||||
|
||||
if (!m_algorithm.isForced()) {
|
||||
if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
if (m_algorithm.variant() == VARIANT_XTL && m_blob[0] >= 9) {
|
||||
m_algorithm.setVariant(VARIANT_HALF);
|
||||
}
|
||||
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
else if (m_algorithm.variant() == VARIANT_MSR && m_blob[0] >= 8) {
|
||||
m_algorithm.setVariant(VARIANT_HALF);
|
||||
}
|
||||
else if (m_algorithm.variant() == xmrig::VARIANT_WOW && m_blob[0] < 11) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_2);
|
||||
else if (m_algorithm.variant() == VARIANT_WOW && m_blob[0] < 11) {
|
||||
m_algorithm.setVariant(VARIANT_2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ bool Job::setBlob(const char *blob)
|
|||
}
|
||||
|
||||
|
||||
bool Job::setTarget(const char *target)
|
||||
bool xmrig::Job::setTarget(const char *target)
|
||||
{
|
||||
if (!target) {
|
||||
return false;
|
||||
|
@ -190,7 +190,7 @@ bool Job::setTarget(const char *target)
|
|||
}
|
||||
|
||||
|
||||
void Job::setAlgorithm(const char *algo)
|
||||
void xmrig::Job::setAlgorithm(const char *algo)
|
||||
{
|
||||
m_algorithm.parseAlgorithm(algo);
|
||||
|
||||
|
@ -200,13 +200,13 @@ void Job::setAlgorithm(const char *algo)
|
|||
}
|
||||
|
||||
|
||||
void Job::setHeight(uint64_t height)
|
||||
void xmrig::Job::setHeight(uint64_t height)
|
||||
{
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
|
||||
bool Job::fromHex(const char* in, unsigned int len, unsigned char* out)
|
||||
bool xmrig::Job::fromHex(const char* in, unsigned int len, unsigned char* out)
|
||||
{
|
||||
bool error = false;
|
||||
for (unsigned int i = 0; i < len; i += 2) {
|
||||
|
@ -220,7 +220,7 @@ bool Job::fromHex(const char* in, unsigned int len, unsigned char* out)
|
|||
}
|
||||
|
||||
|
||||
void Job::toHex(const unsigned char* in, unsigned int len, char* out)
|
||||
void xmrig::Job::toHex(const unsigned char* in, unsigned int len, char* out)
|
||||
{
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
out[i * 2] = hf_bin2hex((in[i] & 0xF0) >> 4);
|
||||
|
@ -230,7 +230,7 @@ void Job::toHex(const unsigned char* in, unsigned int len, char* out)
|
|||
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
char *Job::toHex(const unsigned char* in, unsigned int len)
|
||||
char *xmrig::Job::toHex(const unsigned char* in, unsigned int len)
|
||||
{
|
||||
char *out = new char[len * 2 + 1]();
|
||||
toHex(in, len, out);
|
||||
|
@ -240,10 +240,8 @@ char *Job::toHex(const unsigned char* in, unsigned int len)
|
|||
#endif
|
||||
|
||||
|
||||
xmrig::Variant Job::variant() const
|
||||
xmrig::Variant xmrig::Job::variant() const
|
||||
{
|
||||
using namespace xmrig;
|
||||
|
||||
switch (m_algorithm.algo()) {
|
||||
case CRYPTONIGHT:
|
||||
return (m_blob[0] >= 8) ? VARIANT_2 : VARIANT_1;
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include "common/net/Id.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Job
|
||||
{
|
||||
public:
|
||||
|
@ -43,7 +46,7 @@ public:
|
|||
static constexpr const size_t kMaxBlobSize = 128;
|
||||
|
||||
Job();
|
||||
Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmrig::Id &clientId);
|
||||
Job(int poolId, bool nicehash, const Algorithm &algorithm, const Id &clientId);
|
||||
~Job();
|
||||
|
||||
bool isEqual(const Job &other) const;
|
||||
|
@ -57,9 +60,9 @@ public:
|
|||
inline bool setId(const char *id) { return m_id.setId(id); }
|
||||
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); }
|
||||
inline const uint8_t *blob() const { return m_blob; }
|
||||
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
|
||||
inline const xmrig::Id &clientId() const { return m_clientId; }
|
||||
inline const xmrig::Id &id() const { return m_id; }
|
||||
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||
inline const Id &clientId() const { return m_clientId; }
|
||||
inline const Id &id() const { return m_id; }
|
||||
inline int poolId() const { return m_poolId; }
|
||||
inline int threadId() const { return m_threadId; }
|
||||
inline size_t size() const { return m_size; }
|
||||
|
@ -68,7 +71,7 @@ public:
|
|||
inline uint64_t target() const { return m_target; }
|
||||
inline uint64_t height() const { return m_height; }
|
||||
inline void reset() { m_size = 0; m_diff = 0; }
|
||||
inline void setClientId(const xmrig::Id &id) { m_clientId = id; }
|
||||
inline void setClientId(const Id &id) { m_clientId = id; }
|
||||
inline void setPoolId(int poolId) { m_poolId = poolId; }
|
||||
inline void setThreadId(int threadId) { m_threadId = threadId; }
|
||||
inline void setVariant(const char *variant) { m_algorithm.parseVariant(variant); }
|
||||
|
@ -92,7 +95,7 @@ public:
|
|||
inline bool operator!=(const Job &other) const { return !isEqual(other); }
|
||||
|
||||
private:
|
||||
xmrig::Variant variant() const;
|
||||
Variant variant() const;
|
||||
|
||||
bool m_autoVariant;
|
||||
bool m_nicehash;
|
||||
|
@ -113,4 +116,8 @@ private:
|
|||
# endif
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_JOB_H */
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -28,7 +29,7 @@
|
|||
#include "common/net/SubmitResult.h"
|
||||
|
||||
|
||||
SubmitResult::SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId) :
|
||||
xmrig::SubmitResult::SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId) :
|
||||
reqId(reqId),
|
||||
seq(seq),
|
||||
diff(diff),
|
||||
|
@ -39,7 +40,7 @@ SubmitResult::SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int6
|
|||
}
|
||||
|
||||
|
||||
void SubmitResult::done()
|
||||
void xmrig::SubmitResult::done()
|
||||
{
|
||||
elapsed = (uv_hrtime() - start) / 1000000;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -21,13 +22,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SUBMITRESULT_H__
|
||||
#define __SUBMITRESULT_H__
|
||||
#ifndef XMRIG_SUBMITRESULT_H
|
||||
#define XMRIG_SUBMITRESULT_H
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class SubmitResult
|
||||
{
|
||||
public:
|
||||
|
@ -46,4 +50,8 @@ private:
|
|||
uint64_t start;
|
||||
};
|
||||
|
||||
#endif /* __SUBMITRESULT_H__ */
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_SUBMITRESULT_H */
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -37,7 +37,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
Client::Tls::Tls(Client *client) :
|
||||
xmrig::Client::Tls::Tls(Client *client) :
|
||||
m_ready(false),
|
||||
m_buf(),
|
||||
m_fingerprint(),
|
||||
|
@ -57,7 +57,7 @@ Client::Tls::Tls(Client *client) :
|
|||
}
|
||||
|
||||
|
||||
Client::Tls::~Tls()
|
||||
xmrig::Client::Tls::~Tls()
|
||||
{
|
||||
if (m_ctx) {
|
||||
SSL_CTX_free(m_ctx);
|
||||
|
@ -69,7 +69,7 @@ Client::Tls::~Tls()
|
|||
}
|
||||
|
||||
|
||||
bool Client::Tls::handshake()
|
||||
bool xmrig::Client::Tls::handshake()
|
||||
{
|
||||
m_ssl = SSL_new(m_ctx);
|
||||
assert(m_ssl != nullptr);
|
||||
|
@ -86,7 +86,7 @@ bool Client::Tls::handshake()
|
|||
}
|
||||
|
||||
|
||||
bool Client::Tls::send(const char *data, size_t size)
|
||||
bool xmrig::Client::Tls::send(const char *data, size_t size)
|
||||
{
|
||||
SSL_write(m_ssl, data, size);
|
||||
|
||||
|
@ -94,19 +94,19 @@ bool Client::Tls::send(const char *data, size_t size)
|
|||
}
|
||||
|
||||
|
||||
const char *Client::Tls::fingerprint() const
|
||||
const char *xmrig::Client::Tls::fingerprint() const
|
||||
{
|
||||
return m_ready ? m_fingerprint : nullptr;
|
||||
}
|
||||
|
||||
|
||||
const char *Client::Tls::version() const
|
||||
const char *xmrig::Client::Tls::version() const
|
||||
{
|
||||
return m_ready ? SSL_get_version(m_ssl) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
void Client::Tls::read(const char *data, size_t size)
|
||||
void xmrig::Client::Tls::read(const char *data, size_t size)
|
||||
{
|
||||
BIO_write(m_readBio, data, size);
|
||||
|
||||
|
@ -139,13 +139,13 @@ void Client::Tls::read(const char *data, size_t size)
|
|||
}
|
||||
|
||||
|
||||
bool Client::Tls::send()
|
||||
bool xmrig::Client::Tls::send()
|
||||
{
|
||||
return m_client->send(m_writeBio);
|
||||
}
|
||||
|
||||
|
||||
bool Client::Tls::verify(X509 *cert)
|
||||
bool xmrig::Client::Tls::verify(X509 *cert)
|
||||
{
|
||||
if (cert == nullptr) {
|
||||
LOG_ERR("[%s] Failed to get server certificate", m_client->m_pool.url());
|
||||
|
@ -169,7 +169,7 @@ bool Client::Tls::verify(X509 *cert)
|
|||
}
|
||||
|
||||
|
||||
bool Client::Tls::verifyFingerprint(X509 *cert)
|
||||
bool xmrig::Client::Tls::verifyFingerprint(X509 *cert)
|
||||
{
|
||||
const EVP_MD *digest = EVP_get_digestbyname("sha256");
|
||||
if (digest == nullptr) {
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -31,7 +32,7 @@
|
|||
#include "common/net/Client.h"
|
||||
|
||||
|
||||
class Client::Tls
|
||||
class xmrig::Client::Tls
|
||||
{
|
||||
public:
|
||||
Tls(Client *client);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "common/Platform.h"
|
||||
|
||||
|
||||
FailoverStrategy::FailoverStrategy(const std::vector<Pool> &urls, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||
xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &urls, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||
m_quiet(quiet),
|
||||
m_retries(retries),
|
||||
m_retryPause(retryPause),
|
||||
|
@ -43,7 +43,7 @@ FailoverStrategy::FailoverStrategy(const std::vector<Pool> &urls, int retryPause
|
|||
}
|
||||
|
||||
|
||||
FailoverStrategy::~FailoverStrategy()
|
||||
xmrig::FailoverStrategy::~FailoverStrategy()
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
client->deleteLater();
|
||||
|
@ -51,7 +51,7 @@ FailoverStrategy::~FailoverStrategy()
|
|||
}
|
||||
|
||||
|
||||
int64_t FailoverStrategy::submit(const JobResult &result)
|
||||
int64_t xmrig::FailoverStrategy::submit(const JobResult &result)
|
||||
{
|
||||
if (m_active == -1) {
|
||||
return -1;
|
||||
|
@ -61,13 +61,13 @@ int64_t FailoverStrategy::submit(const JobResult &result)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::connect()
|
||||
void xmrig::FailoverStrategy::connect()
|
||||
{
|
||||
m_pools[m_index]->connect();
|
||||
}
|
||||
|
||||
|
||||
void FailoverStrategy::resume()
|
||||
void xmrig::FailoverStrategy::resume()
|
||||
{
|
||||
if (!isActive()) {
|
||||
return;
|
||||
|
@ -77,7 +77,7 @@ void FailoverStrategy::resume()
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||
void xmrig::FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
client->setAlgo(algo);
|
||||
|
@ -85,7 +85,7 @@ void FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::stop()
|
||||
void xmrig::FailoverStrategy::stop()
|
||||
{
|
||||
for (size_t i = 0; i < m_pools.size(); ++i) {
|
||||
m_pools[i]->disconnect();
|
||||
|
@ -98,7 +98,7 @@ void FailoverStrategy::stop()
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::tick(uint64_t now)
|
||||
void xmrig::FailoverStrategy::tick(uint64_t now)
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
client->tick(now);
|
||||
|
@ -106,7 +106,7 @@ void FailoverStrategy::tick(uint64_t now)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::onClose(Client *client, int failures)
|
||||
void xmrig::FailoverStrategy::onClose(Client *client, int failures)
|
||||
{
|
||||
if (failures == -1) {
|
||||
return;
|
||||
|
@ -127,7 +127,7 @@ void FailoverStrategy::onClose(Client *client, int failures)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::onJobReceived(Client *client, const Job &job)
|
||||
void xmrig::FailoverStrategy::onJobReceived(Client *client, const Job &job)
|
||||
{
|
||||
if (m_active == client->id()) {
|
||||
m_listener->onJob(this, client, job);
|
||||
|
@ -135,7 +135,7 @@ void FailoverStrategy::onJobReceived(Client *client, const Job &job)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::onLoginSuccess(Client *client)
|
||||
void xmrig::FailoverStrategy::onLoginSuccess(Client *client)
|
||||
{
|
||||
int active = m_active;
|
||||
|
||||
|
@ -156,13 +156,13 @@ void FailoverStrategy::onLoginSuccess(Client *client)
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
void xmrig::FailoverStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
{
|
||||
m_listener->onResultAccepted(this, client, result, error);
|
||||
}
|
||||
|
||||
|
||||
void FailoverStrategy::add(const Pool &pool)
|
||||
void xmrig::FailoverStrategy::add(const Pool &pool)
|
||||
{
|
||||
Client *client = new Client((int) m_pools.size(), Platform::userAgent(), this);
|
||||
client->setPool(pool);
|
||||
|
|
|
@ -34,9 +34,11 @@
|
|||
#include "common/interfaces/IStrategy.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client;
|
||||
class IStrategyListener;
|
||||
class Url;
|
||||
|
||||
|
||||
class FailoverStrategy : public IStrategy, public IClientListener
|
||||
|
@ -51,7 +53,7 @@ public:
|
|||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void resume() override;
|
||||
void setAlgo(const xmrig::Algorithm &algo) override;
|
||||
void setAlgo(const Algorithm &algo) override;
|
||||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
|
@ -73,4 +75,7 @@ private:
|
|||
std::vector<Client*> m_pools;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* XMRIG_FAILOVERSTRATEGY_H */
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "common/Platform.h"
|
||||
|
||||
|
||||
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_listener(listener)
|
||||
{
|
||||
|
@ -41,25 +41,25 @@ SinglePoolStrategy::SinglePoolStrategy(const Pool &pool, int retryPause, int ret
|
|||
}
|
||||
|
||||
|
||||
SinglePoolStrategy::~SinglePoolStrategy()
|
||||
xmrig::SinglePoolStrategy::~SinglePoolStrategy()
|
||||
{
|
||||
m_client->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
int64_t SinglePoolStrategy::submit(const JobResult &result)
|
||||
int64_t xmrig::SinglePoolStrategy::submit(const JobResult &result)
|
||||
{
|
||||
return m_client->submit(result);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::connect()
|
||||
void xmrig::SinglePoolStrategy::connect()
|
||||
{
|
||||
m_client->connect();
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::resume()
|
||||
void xmrig::SinglePoolStrategy::resume()
|
||||
{
|
||||
if (!isActive()) {
|
||||
return;
|
||||
|
@ -69,25 +69,25 @@ void SinglePoolStrategy::resume()
|
|||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||
void xmrig::SinglePoolStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||
{
|
||||
m_client->setAlgo(algo);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::stop()
|
||||
void xmrig::SinglePoolStrategy::stop()
|
||||
{
|
||||
m_client->disconnect();
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::tick(uint64_t now)
|
||||
void xmrig::SinglePoolStrategy::tick(uint64_t now)
|
||||
{
|
||||
m_client->tick(now);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onClose(Client *client, int failures)
|
||||
void xmrig::SinglePoolStrategy::onClose(Client *client, int failures)
|
||||
{
|
||||
if (!isActive()) {
|
||||
return;
|
||||
|
@ -98,20 +98,20 @@ void SinglePoolStrategy::onClose(Client *client, int failures)
|
|||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onJobReceived(Client *client, const Job &job)
|
||||
void xmrig::SinglePoolStrategy::onJobReceived(Client *client, const Job &job)
|
||||
{
|
||||
m_listener->onJob(this, client, job);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onLoginSuccess(Client *client)
|
||||
void xmrig::SinglePoolStrategy::onLoginSuccess(Client *client)
|
||||
{
|
||||
m_active = true;
|
||||
m_listener->onActive(this, client);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
void xmrig::SinglePoolStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
{
|
||||
m_listener->onResultAccepted(this, client, result, error);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#include "common/interfaces/IStrategy.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Client;
|
||||
class IStrategyListener;
|
||||
class Pool;
|
||||
|
@ -47,7 +50,7 @@ public:
|
|||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void resume() override;
|
||||
void setAlgo(const xmrig::Algorithm &algo) override;
|
||||
void setAlgo(const Algorithm &algo) override;
|
||||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
|
@ -63,4 +66,8 @@ private:
|
|||
IStrategyListener *m_listener;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_SINGLEPOOLSTRATEGY_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue