xmrig v2.13.0 rebase

This commit is contained in:
MoneroOcean 2019-02-21 15:54:11 -08:00
commit cb22009ee5
111 changed files with 5210 additions and 1292 deletions

View file

@ -5,8 +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 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
@ -36,40 +36,9 @@
#include "Platform.h"
char Platform::m_defaultConfigName[520] = { 0 };
xmrig::String Platform::m_userAgent;
const char *Platform::defaultConfigName()
{
size_t size = 520;
if (*m_defaultConfigName) {
return m_defaultConfigName;
}
if (uv_exepath(m_defaultConfigName, &size) < 0) {
return nullptr;
}
if (size < 500) {
# ifdef WIN32
char *p = strrchr(m_defaultConfigName, '\\');
# else
char *p = strrchr(m_defaultConfigName, '/');
# endif
if (p) {
strcpy(p + 1, "config.json");
return m_defaultConfigName;
}
}
*m_defaultConfigName = '\0';
return nullptr;
}
void Platform::init(const char *userAgent)
{
# ifndef XMRIG_NO_TLS

View file

@ -5,8 +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 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
@ -36,19 +36,17 @@ class Platform
{
public:
static bool setThreadAffinity(uint64_t cpu_id);
static const char *defaultConfigName();
static uint32_t setTimerResolution(uint32_t resolution);
static void init(const char *userAgent);
static void restoreTimerResolution();
static void setProcessPriority(int priority);
static void setThreadPriority(int priority);
static inline const char *userAgent() { return m_userAgent.data(); }
static inline const char *userAgent() { return m_userAgent; }
private:
static char *createUserAgent();
static char m_defaultConfigName[520];
static xmrig::String m_userAgent;
};

View file

@ -5,8 +5,9 @@
* 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 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -54,6 +55,7 @@
#endif
#include "base/io/Json.h"
#include "common/config/CommonConfig.h"
#include "common/log/Log.h"
#include "donate.h"
@ -70,31 +72,22 @@ xmrig::CommonConfig::CommonConfig() :
m_apiRestricted(true),
m_autoSave(true),
m_background(false),
m_colors(true),
m_dryRun(false),
m_calibrateAlgo(false),
m_calibrateAlgoTime(60),
m_syslog(false),
# ifdef XMRIG_PROXY_PROJECT
m_watch(true),
# else
m_watch(false), // TODO: enable config file watch by default when this feature propertly handled and tested.
# endif
m_apiPort(0),
m_donateLevel(kDefaultDonateLevel),
m_printTime(60),
m_retries(5),
m_retryPause(5),
m_state(NoneState)
{
m_pools.push_back(Pool());
}
# ifdef XMRIG_PROXY_PROJECT
m_retries = 2;
m_retryPause = 1;
# endif
bool xmrig::CommonConfig::isColors() const
{
return Log::colors;
}
@ -114,32 +107,7 @@ void xmrig::CommonConfig::printAPI()
void xmrig::CommonConfig::printPools()
{
for (size_t i = 0; i < m_activePools.size(); ++i) {
if (!isColors()) {
Log::i()->text(" * POOL #%-7zu%s variant=%s, TLS=%d",
i + 1,
m_activePools[i].url(),
m_activePools[i].algorithm().variantName(),
static_cast<int>(m_activePools[i].isTLS())
);
}
else {
Log::i()->text(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") "\x1B[1;%dm%s\x1B[0m variant " WHITE_BOLD("%s"),
i + 1,
m_activePools[i].isTLS() ? 32 : 36,
m_activePools[i].url(),
m_activePools[i].algorithm().variantName()
);
}
}
# ifdef APP_DEBUG
LOG_NOTICE("POOLS --------------------------------------------------------------------");
for (const Pool &pool : m_activePools) {
pool.print();
}
LOG_NOTICE("--------------------------------------------------------------------------");
# endif
m_pools.print();
}
@ -206,31 +174,15 @@ bool xmrig::CommonConfig::save()
return false;
}
uv_fs_t req;
const int fd = uv_fs_open(uv_default_loop(), &req, m_fileName.data(), O_WRONLY | O_CREAT | O_TRUNC, 0644, nullptr);
if (fd < 0) {
return false;
}
uv_fs_req_cleanup(&req);
rapidjson::Document doc;
getJSON(doc);
FILE *fp = fdopen(fd, "w");
if (Json::save(m_fileName, doc)) {
LOG_NOTICE("configuration saved to: \"%s\"", m_fileName.data());
return true;
}
char buf[4096];
rapidjson::FileWriteStream os(fp, buf, sizeof(buf));
rapidjson::PrettyWriter<rapidjson::FileWriteStream> writer(os);
doc.Accept(writer);
fflush(fp);
uv_fs_close(uv_default_loop(), &req, fd, nullptr);
uv_fs_req_cleanup(&req);
LOG_NOTICE("configuration saved to: \"%s\"", m_fileName.data());
return true;
return false;
}
@ -248,23 +200,9 @@ bool xmrig::CommonConfig::finalize()
return false;
}
for (Pool &pool : m_pools) {
pool.adjust(m_algorithm);
m_pools.adjust(m_algorithm);
if (pool.isValid() && pool.algorithm().isValid()) {
# ifdef XMRIG_NO_TLS
if (pool.isTLS()) {
continue;
}
# endif
m_activePools.push_back(std::move(pool));
}
}
m_pools.clear();
if (m_activePools.empty()) {
if (!m_pools.active()) {
m_state = ErrorState;
return false;
}
@ -286,21 +224,21 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
break;
case KeepAliveKey: /* --keepalive */
currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
m_pools.setKeepAlive(enable);
break;
case TlsKey: /* --tls */
currentPool().setTLS(enable);
m_pools.setTLS(enable);
break;
# ifndef XMRIG_PROXY_PROJECT
case NicehashKey: /* --nicehash */
currentPool().setNicehash(enable);
m_pools.setNicehash(enable);
break;
# endif
case ColorKey: /* --no-color */
m_colors = enable;
Log::colors = enable;
break;
case WatchKey: /* watch */
@ -343,50 +281,29 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
break;
case UserpassKey: /* --userpass */
if (!currentPool().setUserpass(arg)) {
return false;
}
break;
return m_pools.setUserpass(arg);
case UrlKey: /* --url */
fixup();
if (m_pools.size() > 1 || m_pools[0].isValid()) {
Pool pool(arg);
if (pool.isValid()) {
m_pools.push_back(std::move(pool));
}
}
else {
m_pools[0].parse(arg);
}
if (!m_pools.back().isValid()) {
return false;
}
break;
return m_pools.setUrl(arg);
case UserKey: /* --user */
currentPool().setUser(arg);
m_pools.setUser(arg);
break;
case PasswordKey: /* --pass */
currentPool().setPassword(arg);
m_pools.setPassword(arg);
break;
case RigIdKey: /* --rig-id */
currentPool().setRigId(arg);
m_pools.setRigId(arg);
break;
case FingerprintKey: /* --tls-fingerprint */
currentPool().setFingerprint(arg);
m_pools.setFingerprint(arg);
break;
case VariantKey: /* --variant */
currentPool().algorithm().parseVariant(arg);
m_pools.setVariant(arg);
break;
case LogFileKey: /* --log-file */
@ -456,6 +373,15 @@ bool xmrig::CommonConfig::parseUint64(int key, uint64_t arg)
}
void xmrig::CommonConfig::parseJSON(const rapidjson::Document &doc)
{
const rapidjson::Value &pools = doc["pools"];
if (pools.IsArray()) {
m_pools.load(pools);
}
}
void xmrig::CommonConfig::setFileName(const char *fileName)
{
m_fileName = fileName;
@ -466,23 +392,19 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
{
switch (key) {
case RetriesKey: /* --retries */
if (arg > 0 && arg <= 1000) {
m_retries = arg;
}
m_pools.setRetries(arg);
break;
case RetryPauseKey: /* --retry-pause */
if (arg > 0 && arg <= 3600) {
m_retryPause = arg;
}
m_pools.setRetryPause(arg);
break;
case KeepAliveKey: /* --keepalive */
currentPool().setKeepAlive(arg);
m_pools.setKeepAlive(arg);
break;
case VariantKey: /* --variant */
currentPool().algorithm().parseVariant(arg);
m_pools.setVariant(arg);
break;
case DonateLevelKey: /* --donate-level */
@ -515,30 +437,3 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
return true;
}
Pool &xmrig::CommonConfig::currentPool()
{
fixup();
return m_pools.back();
}
void xmrig::CommonConfig::fixup()
{
if (m_state == NoneState) {
return;
}
if (m_pools.empty()) {
if (!m_activePools.empty()) {
std::swap(m_pools, m_activePools);
}
else {
m_pools.push_back(Pool());
}
m_state = NoneState;
}
}

View file

@ -5,8 +5,9 @@
* 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 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -26,12 +27,9 @@
#define XMRIG_COMMONCONFIG_H
#include <vector>
#include "base/net/Pools.h"
#include "base/tools/String.h"
#include "common/interfaces/IConfig.h"
#include "common/net/Pool.h"
#include "common/utils/c_str.h"
#include "common/xmrig.h"
@ -47,7 +45,6 @@ public:
inline bool isApiRestricted() const { return m_apiRestricted; }
inline bool isAutoSave() const { return m_autoSave; }
inline bool isBackground() const { return m_background; }
inline bool isColors() const { return m_colors; }
inline bool isDryRun() const { return m_dryRun; }
inline bool isCalibrateAlgo() const { return m_calibrateAlgo; }
inline int calibrateAlgoTime() const { return m_calibrateAlgoTime; }
@ -57,21 +54,19 @@ public:
inline const char *apiWorkerId() const { return m_apiWorkerId.data(); }
inline const char *logFile() const { return m_logFile.data(); }
inline const char *userAgent() const { return m_userAgent.data(); }
inline const std::vector<Pool> &pools() const { return m_activePools; }
inline const Pools &pools() const { return m_pools; }
inline int apiPort() const { return m_apiPort; }
inline int donateLevel() const { return m_donateLevel; }
inline void setDonateLevel(const int donate) { m_donateLevel = donate; }
inline int printTime() const { return m_printTime; }
inline int retries() const { return m_retries; }
inline int retryPause() const { return m_retryPause; }
inline void setColors(bool colors) { m_colors = colors; }
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
inline const Algorithm &algorithm() const override { return m_algorithm; }
inline const char *fileName() const override { return m_fileName.data(); }
inline const String &fileName() const override { return m_fileName; }
bool save() override;
bool isColors() const;
void printAPI();
void printPools();
void printVersions();
@ -87,6 +82,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;
@ -95,7 +91,6 @@ protected:
bool m_apiRestricted;
bool m_autoSave;
bool m_background;
bool m_colors;
bool m_dryRun;
bool m_calibrateAlgo;
int m_calibrateAlgoTime;
@ -104,22 +99,17 @@ protected:
int m_apiPort;
int m_donateLevel;
int m_printTime;
int m_retries;
int m_retryPause;
Pools m_pools;
State m_state;
std::vector<Pool> m_activePools;
std::vector<Pool> m_pools;
xmrig::c_str m_apiId;
xmrig::c_str m_apiToken;
xmrig::c_str m_apiWorkerId;
xmrig::c_str m_fileName;
xmrig::c_str m_logFile;
xmrig::c_str 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);
Pool &currentPool();
void fixup();
};

View file

@ -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
@ -22,6 +23,7 @@
*/
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <uv.h>
@ -37,23 +39,23 @@
#endif
#include "base/io/Json.h"
#include "base/kernel/interfaces/IConfigListener.h"
#include "base/kernel/Process.h"
#include "common/config/ConfigLoader.h"
#include "common/config/ConfigWatcher.h"
#include "common/interfaces/IConfig.h"
#include "common/interfaces/IWatcherListener.h"
#include "common/net/Pool.h"
#include "common/Platform.h"
#include "core/ConfigCreator.h"
#include "core/ConfigLoader_platform.h"
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/fwd.h"
bool xmrig::ConfigLoader::m_done = false;
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr;
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
#ifndef ARRAY_SIZE
@ -76,8 +78,9 @@ bool xmrig::ConfigLoader::loadFromFile(xmrig::IConfig *config, const char *fileN
bool xmrig::ConfigLoader::loadFromJSON(xmrig::IConfig *config, const char *json)
{
rapidjson::Document doc;
doc.Parse(json);
using namespace rapidjson;
Document doc;
doc.Parse<kParseCommentsFlag | kParseTrailingCommasFlag>(json);
if (doc.HasParseError() || !doc.IsObject()) {
return false;
@ -93,19 +96,6 @@ bool xmrig::ConfigLoader::loadFromJSON(xmrig::IConfig *config, const rapidjson::
parseJSON(config, &config_options[i], doc);
}
const rapidjson::Value &pools = doc["pools"];
if (pools.IsArray()) {
for (const rapidjson::Value &value : pools.GetArray()) {
if (!value.IsObject()) {
continue;
}
for (size_t i = 0; i < ARRAY_SIZE(pool_options); i++) {
parseJSON(config, &pool_options[i], value);
}
}
}
const rapidjson::Value &api = doc["api"];
if (api.IsObject()) {
for (size_t i = 0; i < ARRAY_SIZE(api_options); i++) {
@ -142,16 +132,31 @@ bool xmrig::ConfigLoader::reload(xmrig::IConfig *oldConfig, const char *json)
}
xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener)
bool xmrig::ConfigLoader::watch(IConfig *config)
{
if (!config->isWatch()) {
return false;
}
assert(m_watcher == nullptr);
m_watcher = new xmrig::ConfigWatcher(config->fileName(), m_creator, m_listener);
return true;
}
xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *creator, IConfigListener *listener)
{
m_creator = creator;
m_listener = listener;
xmrig::IConfig *config = m_creator->create();
int key;
int argc = process->arguments().argc();
char **argv = process->arguments().argv();
while (1) {
key = getopt_long(argc, argv, short_options, options, NULL);
key = getopt_long(argc, argv, short_options, options, nullptr);
if (key < 0) {
break;
}
@ -172,7 +177,7 @@ xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator
delete config;
config = m_creator->create();
loadFromFile(config, Platform::defaultConfigName());
loadFromFile(config, process->location(Process::ExeLocation, "config.json"));
}
if (!config->finalize()) {
@ -187,10 +192,6 @@ xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator
return nullptr;
}
if (config->isWatch()) {
m_watcher = new xmrig::ConfigWatcher(config->fileName(), creator, listener);
}
return config;
}
@ -207,53 +208,28 @@ void xmrig::ConfigLoader::release()
bool xmrig::ConfigLoader::getJSON(const char *fileName, rapidjson::Document &doc)
{
uv_fs_t req;
const int fd = uv_fs_open(uv_default_loop(), &req, fileName, O_RDONLY, 0644, nullptr);
if (fd < 0) {
fprintf(stderr, "unable to open %s: %s\n", fileName, uv_strerror(fd));
return false;
if (Json::get(fileName, doc)) {
return true;
}
uv_fs_req_cleanup(&req);
FILE *fp = fdopen(fd, "rb");
char buf[8192];
rapidjson::FileReadStream is(fp, buf, sizeof(buf));
doc.ParseStream(is);
uv_fs_close(uv_default_loop(), &req, fd, nullptr);
uv_fs_req_cleanup(&req);
if (doc.HasParseError()) {
printf("%s<%d>: %s\n", fileName, (int) doc.GetErrorOffset(), rapidjson::GetParseError_En(doc.GetParseError()));
return false;
printf("%s<offset:%zu>: \"%s\"\n", fileName, doc.GetErrorOffset(), rapidjson::GetParseError_En(doc.GetParseError()));
}
else {
fprintf(stderr, "unable to open \"%s\".\n", fileName);
}
return doc.IsObject();
return false;
}
bool xmrig::ConfigLoader::parseArg(xmrig::IConfig *config, int key, const char *arg)
{
switch (key) {
case xmrig::IConfig::VersionKey: /* --version */
showVersion();
return false;
case xmrig::IConfig::HelpKey: /* --help */
showUsage();
return false;
case xmrig::IConfig::ConfigKey: /* --config */
loadFromFile(config, arg);
break;
default:
return config->parseString(key, arg);;
if (key == xmrig::IConfig::ConfigKey) {
return loadFromFile(config, arg);
}
return true;
return config->parseString(key, arg);
}
@ -280,56 +256,3 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
config->parseBoolean(option->val, value.IsTrue());
}
}
void xmrig::ConfigLoader::showUsage()
{
m_done = true;
printf(usage);
}
void xmrig::ConfigLoader::showVersion()
{
m_done = true;
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
# if defined(__clang__)
" with clang " __clang_version__);
# elif defined(__GNUC__)
" with GCC");
printf(" %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# elif defined(_MSC_VER)
" with MSVC");
printf(" %d", MSVC_VERSION);
# else
);
# endif
printf("\n features:"
# if defined(__i386__) || defined(_M_IX86)
" 32-bit"
# elif defined(__x86_64__) || defined(_M_AMD64)
" 64-bit"
# endif
# if defined(__AES__) || defined(_MSC_VER)
" AES"
# endif
"\n");
printf("\nlibuv/%s\n", uv_version_string());
# ifndef XMRIG_NO_HTTPD
printf("microhttpd/%s\n", MHD_get_version());
# endif
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
{
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
printf("OpenSSL/%.*s\n", static_cast<int>(strchr(v, ' ') - v), v);
}
# endif
}

View file

@ -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,8 +40,9 @@ namespace xmrig {
class ConfigWatcher;
class IConfigCreator;
class IWatcherListener;
class IConfigListener;
class IConfig;
class Process;
class ConfigLoader
@ -50,22 +52,18 @@ public:
static bool loadFromJSON(IConfig *config, const char *json);
static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc);
static bool reload(IConfig *oldConfig, const char *json);
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener);
static bool watch(IConfig *config);
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
static void release();
static inline bool isDone() { return m_done; }
private:
static bool getJSON(const char *fileName, rapidjson::Document &doc);
static bool parseArg(IConfig *config, int key, const char *arg);
static void parseJSON(IConfig *config, const struct option *option, const rapidjson::Value &object);
static void showUsage();
static void showVersion();
static bool m_done;
static ConfigWatcher *m_watcher;
static IConfigCreator *m_creator;
static IWatcherListener *m_listener;
static IConfigListener *m_listener;
};

View file

@ -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
@ -22,66 +23,35 @@
*/
#include <stdio.h>
#include "base/io/Watcher.h"
#include "base/kernel/interfaces/IConfigListener.h"
#include "common/config/ConfigLoader.h"
#include "common/config/ConfigWatcher.h"
#include "common/interfaces/IWatcherListener.h"
#include "common/log/Log.h"
#include "core/ConfigCreator.h"
xmrig::ConfigWatcher::ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener) :
xmrig::ConfigWatcher::ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener) :
m_creator(creator),
m_listener(listener),
m_path(path)
m_listener(listener)
{
uv_fs_event_init(uv_default_loop(), &m_fsEvent);
uv_timer_init(uv_default_loop(), &m_timer);
m_fsEvent.data = m_timer.data = this;
start();
m_watcher = new Watcher(path, this);
}
xmrig::ConfigWatcher::~ConfigWatcher()
{
uv_timer_stop(&m_timer);
uv_fs_event_stop(&m_fsEvent);
delete m_watcher;
}
void xmrig::ConfigWatcher::onTimer(uv_timer_t* handle)
void xmrig::ConfigWatcher::onFileChanged(const String &fileName)
{
static_cast<xmrig::ConfigWatcher *>(handle->data)->reload();
}
void xmrig::ConfigWatcher::onFsEvent(uv_fs_event_t* handle, const char *filename, int events, int status)
{
if (!filename) {
return;
}
static_cast<xmrig::ConfigWatcher *>(handle->data)->queueUpdate();
}
void xmrig::ConfigWatcher::queueUpdate()
{
uv_timer_stop(&m_timer);
uv_timer_start(&m_timer, xmrig::ConfigWatcher::onTimer, kDelay, 0);
}
void xmrig::ConfigWatcher::reload()
{
LOG_WARN("\"%s\" was changed, reloading configuration", m_path.data());
LOG_WARN("\"%s\" was changed, reloading configuration", fileName.data());
IConfig *config = m_creator->create();
ConfigLoader::loadFromFile(config, m_path.data());
ConfigLoader::loadFromFile(config, fileName);
if (!config->finalize()) {
LOG_ERR("reloading failed");
@ -91,15 +61,4 @@ void xmrig::ConfigWatcher::reload()
}
m_listener->onNewConfig(config);
# ifndef _WIN32
uv_fs_event_stop(&m_fsEvent);
start();
# endif
}
void xmrig::ConfigWatcher::start()
{
uv_fs_event_start(&m_fsEvent, xmrig::ConfigWatcher::onFsEvent, m_path.data(), 0);
}

View file

@ -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,15 +22,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CONFIGWATCHER_H__
#define __CONFIGWATCHER_H__
#ifndef XMRIG_CONFIGWATCHER_H
#define XMRIG_CONFIGWATCHER_H
#include <stdint.h>
#include <uv.h>
#include "common/utils/c_str.h"
#include "base/kernel/interfaces/IWatcherListener.h"
#include "base/tools/String.h"
#include "rapidjson/fwd.h"
@ -40,29 +38,23 @@ namespace xmrig {
class IConfigCreator;
class IWatcherListener;
class IConfigListener;
class Watcher;
class ConfigWatcher
class ConfigWatcher : public IWatcherListener
{
public:
ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener);
~ConfigWatcher();
ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener);
~ConfigWatcher() override;
protected:
void onFileChanged(const String &fileName) override;
private:
constexpr static int kDelay = 500;
static void onFsEvent(uv_fs_event_t* handle, const char *filename, int events, int status);
static void onTimer(uv_timer_t* handle);
void queueUpdate();
void reload();
void start();
IConfigCreator *m_creator;
IWatcherListener *m_listener;
uv_fs_event_t m_fsEvent;
uv_timer_t m_timer;
xmrig::c_str m_path;
IConfigListener *m_listener;
Watcher *m_watcher;
};

View file

@ -66,6 +66,8 @@ static AlgoData const algorithms[] = {
{ "cryptonight/half", "cn/half", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
{ "cryptonight/xtlv9", "cn/xtlv9", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
{ "cryptonight/wow", "cn/wow", xmrig::CRYPTONIGHT, xmrig::VARIANT_WOW },
{ "cryptonight/r", "cn/r", xmrig::CRYPTONIGHT, xmrig::VARIANT_4 },
{ "cryptonight/4", "cn/4", xmrig::CRYPTONIGHT, xmrig::VARIANT_4 },
# ifndef XMRIG_NO_AEON
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
@ -131,6 +133,7 @@ static const char *variants[] = {
"trtl",
"gpu",
"wow",
"4",
};
@ -296,7 +299,7 @@ const char *xmrig::Algorithm::perfAlgoName(const xmrig::PerfAlgo pa) {
"cn/2",
"cn/half",
"cn/gpu",
"cn/wow",
"cn/4",
"cn-lite",
"cn-heavy",
"cn-pico",
@ -323,9 +326,9 @@ xmrig::Algorithm::Algorithm(const xmrig::PerfAlgo pa) {
m_algo = xmrig::CRYPTONIGHT;
m_variant = xmrig::VARIANT_GPU;
break;
case PA_CN_WOW:
case PA_CN4:
m_algo = xmrig::CRYPTONIGHT;
m_variant = xmrig::VARIANT_WOW;
m_variant = xmrig::VARIANT_4;
break;
case PA_CN_LITE:
m_algo = xmrig::CRYPTONIGHT_LITE;
@ -353,7 +356,7 @@ xmrig::PerfAlgo xmrig::Algorithm::perf_algo() const {
case VARIANT_2: return PA_CN2;
case VARIANT_HALF: return PA_CN_HALF;
case VARIANT_GPU: return PA_CN_GPU;
case VARIANT_WOW: return PA_CN_WOW;
case VARIANT_4: return PA_CN4;
default: return PA_CN;
}
case CRYPTONIGHT_LITE: return PA_CN_LITE;

View file

@ -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>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*

View file

@ -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,13 +22,16 @@
* 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>
namespace xmrig {
class Client;
class Job;
class SubmitResult;
@ -36,7 +40,7 @@ class SubmitResult;
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 +49,7 @@ public:
};
#endif // __ICLIENTLISTENER_H__
} /* namespace xmrig */
#endif // XMRIG_ICLIENTLISTENER_H

View file

@ -4,8 +4,10 @@
* 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-2018 XMRig <support@xmrig.com>
* Copyright 2018 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
* 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>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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
@ -32,6 +34,9 @@
namespace xmrig {
class String;
class IConfig
{
public:
@ -48,7 +53,6 @@ public:
ColorKey = 1002,
ConfigKey = 'c',
DonateLevelKey = 1003,
HelpKey = 'h',
KeepAliveKey = 'k',
LogFileKey = 'l',
PasswordKey = 'p',
@ -62,7 +66,6 @@ public:
UserpassKey = 'O',
VariantKey = 1010,
VerboseKey = 1100,
VersionKey = 'V',
WatchKey = 1105,
TlsKey = 1013,
FingerprintKey = 1014,
@ -128,7 +131,7 @@ public:
CudaMaxUsageKey = 1206,
};
virtual ~IConfig() {}
virtual ~IConfig() = default;
virtual bool finalize() = 0;
virtual bool isWatch() const = 0;
@ -137,7 +140,7 @@ public:
virtual bool parseUint64(int key, uint64_t arg) = 0;
virtual bool save() = 0;
virtual const Algorithm &algorithm() const = 0;
virtual const char *fileName() const = 0;
virtual const String &fileName() const = 0;
virtual void getJSON(rapidjson::Document &doc) const = 0;
virtual void parseJSON(const rapidjson::Document &doc) = 0;
virtual void setFileName(const char *fileName) = 0;

View file

@ -4,7 +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-2018 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
@ -20,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ICONFIGCREATOR_H__
#define __ICONFIGCREATOR_H__
#ifndef XMRIG_ICONFIGCREATOR_H
#define XMRIG_ICONFIGCREATOR_H
namespace xmrig {
@ -33,7 +35,7 @@ class IConfig;
class IConfigCreator
{
public:
virtual ~IConfigCreator() {}
virtual ~IConfigCreator() = default;
virtual IConfig *create() const = 0;
};
@ -42,4 +44,4 @@ public:
} /* namespace xmrig */
#endif // __ICONFIGCREATOR_H__
#endif // XMRIG_ICONFIGCREATOR_H

View file

@ -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
@ -34,7 +35,7 @@ class Config;
class IControllerListener
{
public:
virtual ~IControllerListener() {}
virtual ~IControllerListener() = default;
virtual void onConfigChanged(Config *config, Config *previousConfig) = 0;
};

View file

@ -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

View file

@ -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

View file

@ -1,46 +0,0 @@
/* 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 2016-2018 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 __IWATCHERLISTENER_H__
#define __IWATCHERLISTENER_H__
namespace xmrig {
class IConfig;
class IWatcherListener
{
public:
virtual ~IWatcherListener() {}
virtual void onNewConfig(IConfig *config) = 0;
};
} /* namespace xmrig */
#endif // __IWATCHERLISTENER_H__

View file

@ -45,7 +45,7 @@ ConsoleLog::ConsoleLog(xmrig::Controller *controller) :
m_controller(controller)
{
if (uv_tty_init(uv_default_loop(), &m_tty, 1, 0) < 0) {
controller->config()->setColors(false);
Log::colors = false;
return;
}

View file

@ -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
@ -35,9 +36,10 @@
Log *Log::m_self = nullptr;
bool Log::colors = true;
static const char *colors[5] = {
static const char *color[5] = {
"\x1B[0;31m", /* ERR */
"\x1B[0;33m", /* WARNING */
"\x1B[1;37m", /* NOTICE */
@ -96,7 +98,7 @@ const char *Log::colorByLevel(ILogBackend::Level level, bool isColors)
return "";
}
return colors[level];
return color[level];
}

View file

@ -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
@ -48,6 +49,8 @@ public:
static const char *endl(bool isColors = true);
static void defaultInit();
static bool colors;
private:
inline Log() {
assert(m_self == nullptr);

View file

@ -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>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
@ -54,8 +55,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
@ -69,7 +74,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),
@ -106,13 +111,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()) {
@ -129,14 +134,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;
@ -151,7 +156,7 @@ void Client::deleteLater()
void Client::setPool(const Pool &pool)
void xmrig::Client::setPool(const Pool &pool)
{
if (!pool.isValid()) {
return;
@ -161,7 +166,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) {
@ -179,7 +184,7 @@ void Client::tick(uint64_t now)
}
bool Client::disconnect()
bool xmrig::Client::disconnect()
{
m_keepAlive = 0;
m_expire = 0;
@ -189,7 +194,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) {
@ -201,7 +206,7 @@ const char *Client::tlsFingerprint() const
}
const char *Client::tlsVersion() const
const char *xmrig::Client::tlsVersion() const
{
# ifndef XMRIG_NO_TLS
if (isTLS()) {
@ -213,7 +218,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) {
@ -221,10 +226,6 @@ int64_t Client::submit(const JobResult &result)
}
# endif
if (m_job.algorithm().variant() == xmrig::VARIANT_WOW && m_job.id() != result.jobId) {
return -1;
}
using namespace rapidjson;
# ifdef XMRIG_PROXY_PROJECT
@ -270,7 +271,7 @@ int64_t Client::submit(const JobResult &result)
}
bool Client::close()
bool xmrig::Client::close()
{
if (m_state == ClosingState) {
return m_socket != nullptr;
@ -290,7 +291,7 @@ bool Client::close()
}
bool Client::isCriticalError(const char *message)
bool xmrig::Client::isCriticalError(const char *message)
{
if (!message) {
return false;
@ -312,7 +313,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;
@ -322,7 +323,7 @@ bool Client::isTLS() const
}
bool Client::parseJob(const rapidjson::Value &params, int *code)
bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
{
if (!params.IsObject()) {
*code = 2;
@ -399,7 +400,7 @@ bool Client::parseJob(const rapidjson::Value &params, 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;
@ -419,7 +420,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;
@ -452,10 +453,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
@ -479,7 +480,7 @@ bool Client::verifyAlgorithm(const xmrig::Algorithm &algorithm) const
}
int Client::resolve(const char *host)
int xmrig::Client::resolve(const char *host)
{
setState(HostLookupState);
@ -502,7 +503,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;
@ -525,7 +526,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);
@ -556,7 +557,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();
@ -574,7 +575,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);
@ -597,7 +598,7 @@ void Client::connect(sockaddr *addr)
}
void Client::handshake()
void xmrig::Client::handshake()
{
# ifndef XMRIG_NO_TLS
if (isTLS()) {
@ -613,7 +614,7 @@ void Client::handshake()
}
void Client::login()
void xmrig::Client::login()
{
using namespace rapidjson;
m_results.clear();
@ -663,7 +664,7 @@ void Client::login()
}
void Client::onClose()
void xmrig::Client::onClose()
{
delete m_socket;
@ -682,7 +683,7 @@ void Client::onClose()
}
void Client::parse(char *line, size_t len)
void xmrig::Client::parse(char *line, size_t len)
{
startTimeout();
@ -721,7 +722,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;
@ -748,7 +749,7 @@ void Client::parseExtensions(const rapidjson::Value &value)
}
void Client::parseNotification(const char *method, const rapidjson::Value &params, const rapidjson::Value &error)
void xmrig::Client::parseNotification(const char *method, const rapidjson::Value &params, const rapidjson::Value &error)
{
if (error.IsObject()) {
if (!isQuiet()) {
@ -774,7 +775,7 @@ void Client::parseNotification(const char *method, const rapidjson::Value &param
}
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();
@ -826,13 +827,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;
@ -861,7 +862,7 @@ void Client::read()
}
void Client::reconnect()
void xmrig::Client::reconnect()
{
if (!m_listener) {
m_storage.remove(m_key);
@ -884,7 +885,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]);
@ -896,7 +897,7 @@ void Client::setState(SocketState state)
}
void Client::startTimeout()
void xmrig::Client::startTimeout()
{
m_expire = 0;
@ -906,7 +907,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) {
@ -918,7 +919,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) {
@ -929,7 +930,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) {
@ -958,7 +959,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) {
@ -1001,7 +1002,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) {

View file

@ -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>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
@ -31,22 +32,25 @@
#include <vector>
#include "base/net/Pool.h"
#include "common/crypto/Algorithm.h"
#include "common/net/Id.h"
#include "common/net/Job.h"
#include "common/net/Pool.h"
#include "common/net/Storage.h"
#include "common/net/SubmitResult.h"
#include "rapidjson/fwd.h"
typedef struct bio_st BIO;
namespace xmrig {
class IClientListener;
class JobResult;
typedef struct bio_st BIO;
class Client
{
public:
@ -86,7 +90,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; }
@ -106,7 +110,7 @@ private:
bool parseJob(const rapidjson::Value &params, 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);
@ -163,11 +167,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 */

View file

@ -59,7 +59,7 @@ char hf_bin2hex(unsigned char c)
}
Job::Job() :
xmrig::Job::Job() :
m_autoVariant(false),
m_nicehash(false),
m_poolId(-2),
@ -73,8 +73,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),
@ -89,18 +89,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;
@ -129,14 +129,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);
}
}
@ -155,7 +155,7 @@ void Job::setRawBlob(const uint8_t *blob, const size_t size)
}
bool Job::setTarget(const char *target)
bool xmrig::Job::setTarget(const char *target)
{
if (!target) {
return false;
@ -197,7 +197,7 @@ bool Job::setTarget(const char *target)
}
void Job::setAlgorithm(const char *algo)
void xmrig::Job::setAlgorithm(const char *algo)
{
m_algorithm.parseAlgorithm(algo);
@ -207,13 +207,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) {
@ -227,7 +227,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);
@ -237,7 +237,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);
@ -247,13 +247,11 @@ 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;
return (m_blob[0] >= 10) ? VARIANT_4 : ((m_blob[0] >= 8) ? VARIANT_2 : VARIANT_1);
case CRYPTONIGHT_LITE:
return VARIANT_1;

View file

@ -36,6 +36,9 @@
#include "common/net/Id.h"
namespace xmrig {
class Job
{
public:
@ -44,7 +47,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;
@ -61,9 +64,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; }
@ -72,7 +75,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); }
@ -96,7 +99,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;
@ -117,4 +120,8 @@ private:
# endif
};
} /* namespace xmrig */
#endif /* XMRIG_JOB_H */

View file

@ -1,408 +0,0 @@
/* 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-2019 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>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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 <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "common/net/Pool.h"
#include "rapidjson/document.h"
#ifdef APP_DEBUG
# include "common/log/Log.h"
#endif
#ifdef _MSC_VER
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
#endif
Pool::Pool() :
m_nicehash(false),
m_tls(false),
m_keepAlive(0),
m_port(kDefaultPort)
{
// here xmrig now reports all possible supported algorithms
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_1));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_2));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_0));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_XTL));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_MSR));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_RTO));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT, xmrig::VARIANT_WOW));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE));
m_algorithms.push_back(xmrig::Algorithm(xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL));
}
/**
* @brief Parse url.
*
* Valid urls:
* example.com
* example.com:3333
* stratum+tcp://example.com
* stratum+tcp://example.com:3333
*
* @param url
*/
Pool::Pool(const char *url) :
m_nicehash(false),
m_tls(false),
m_keepAlive(0),
m_port(kDefaultPort)
{
parse(url);
}
Pool::Pool(const char *host, uint16_t port, const char *user, const char *password, int keepAlive, bool nicehash, bool tls) :
m_nicehash(nicehash),
m_tls(tls),
m_keepAlive(keepAlive),
m_port(port),
m_host(host),
m_password(password),
m_user(user)
{
const size_t size = m_host.size() + 8;
assert(size > 8);
char *url = static_cast<char *>(malloc(size));
snprintf(url, size - 1, "%s:%d", m_host.data(), m_port);
m_url = url;
}
bool Pool::isCompatible(const xmrig::Algorithm &algorithm) const
{
if (m_algorithms.empty()) {
return true;
}
for (const auto &a : m_algorithms) {
if (algorithm == a) {
return true;
}
}
# ifdef XMRIG_PROXY_PROJECT
if (m_algorithm.algo() == xmrig::CRYPTONIGHT && algorithm.algo() == xmrig::CRYPTONIGHT) {
return m_algorithm.variant() == xmrig::VARIANT_XTL || m_algorithm.variant() == xmrig::VARIANT_MSR;
}
# endif
return false;
}
bool Pool::isEqual(const Pool &other) const
{
return (m_nicehash == other.m_nicehash
&& m_tls == other.m_tls
&& m_keepAlive == other.m_keepAlive
&& m_port == other.m_port
&& m_algorithm == other.m_algorithm
&& m_fingerprint == other.m_fingerprint
&& m_host == other.m_host
&& m_password == other.m_password
&& m_rigId == other.m_rigId
&& m_url == other.m_url
&& m_user == other.m_user);
}
bool Pool::parse(const char *url)
{
assert(url != nullptr);
const char *p = strstr(url, "://");
const char *base = url;
if (p) {
if (strncasecmp(url, "stratum+tcp://", 14) == 0) {
m_tls = false;
}
else if (strncasecmp(url, "stratum+ssl://", 14) == 0) {
m_tls = true;
}
else {
return false;
}
base = url + 14;
}
if (!strlen(base) || *base == '/') {
return false;
}
m_url = url;
if (base[0] == '[') {
return parseIPv6(base);
}
const char *port = strchr(base, ':');
if (!port) {
m_host = base;
return true;
}
const size_t size = port++ - base + 1;
char *host = static_cast<char *>(malloc(size));
memcpy(host, base, size - 1);
host[size - 1] = 0;
m_host = host;
m_port = static_cast<uint16_t>(strtol(port, nullptr, 10));
return true;
}
bool Pool::setUserpass(const char *userpass)
{
const char *p = strchr(userpass, ':');
if (!p) {
return false;
}
char *user = static_cast<char *>(malloc(p - userpass + 1));
strncpy(user, userpass, p - userpass);
m_user = user;
m_password = p + 1;
return true;
}
rapidjson::Value Pool::toJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;
auto &allocator = doc.GetAllocator();
Value obj(kObjectType);
obj.AddMember("url", m_url.toJSON(), allocator);
obj.AddMember("user", m_user.toJSON(), allocator);
obj.AddMember("pass", m_password.toJSON(), allocator);
obj.AddMember("rig-id", m_rigId.toJSON(), allocator);
# ifndef XMRIG_PROXY_PROJECT
obj.AddMember("nicehash", isNicehash(), allocator);
# endif
if (m_keepAlive == 0 || m_keepAlive == kKeepAliveTimeout) {
obj.AddMember("keepalive", m_keepAlive > 0, allocator);
}
else {
obj.AddMember("keepalive", m_keepAlive, allocator);
}
switch (m_algorithm.variant()) {
case xmrig::VARIANT_AUTO:
case xmrig::VARIANT_0:
case xmrig::VARIANT_1:
obj.AddMember("variant", m_algorithm.variant(), allocator);
break;
case xmrig::VARIANT_2:
obj.AddMember("variant", 2, allocator);
break;
default:
obj.AddMember("variant", StringRef(m_algorithm.variantName()), allocator);
break;
}
obj.AddMember("tls", isTLS(), allocator);
obj.AddMember("tls-fingerprint", m_fingerprint.toJSON(), allocator);
return obj;
}
void Pool::adjust(const xmrig::Algorithm &algorithm)
{
if (!isValid()) {
return;
}
if (!m_algorithm.isValid()) {
m_algorithm.setAlgo(algorithm.algo());
adjustVariant(algorithm.variant());
}
}
void Pool::setAlgo(const xmrig::Algorithm &algorithm)
{
m_algorithm = algorithm;
}
#ifdef APP_DEBUG
void Pool::print() const
{
LOG_NOTICE("url: %s", m_url.data());
LOG_DEBUG ("host: %s", m_host.data());
LOG_DEBUG ("port: %d", static_cast<int>(m_port));
LOG_DEBUG ("user: %s", m_user.data());
LOG_DEBUG ("pass: %s", m_password.data());
LOG_DEBUG ("rig-id %s", m_rigId.data());
LOG_DEBUG ("algo: %s", m_algorithm.name());
LOG_DEBUG ("nicehash: %d", static_cast<int>(m_nicehash));
LOG_DEBUG ("keepAlive: %d", m_keepAlive);
}
#endif
bool Pool::parseIPv6(const char *addr)
{
const char *end = strchr(addr, ']');
if (!end) {
return false;
}
const char *port = strchr(end, ':');
if (!port) {
return false;
}
const size_t size = end - addr;
char *host = static_cast<char *>(malloc(size));
memcpy(host, addr + 1, size - 1);
host[size - 1] = 0;
m_host = host;
m_port = static_cast<uint16_t>(strtol(port + 1, nullptr, 10));
return true;
}
void Pool::adjustVariant(const xmrig::Variant variantHint)
{
# ifndef XMRIG_PROXY_PROJECT
using namespace xmrig;
if (m_host.contains(".nicehash.com")) {
m_keepAlive = false;
m_nicehash = true;
bool valid = true;
switch (m_port) {
case 3355:
case 33355:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonight.");
m_algorithm.setVariant(VARIANT_0);
break;
case 3363:
case 33363:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv7.");
m_algorithm.setVariant(VARIANT_1);
break;
case 3364:
valid = m_algorithm.algo() == CRYPTONIGHT_HEAVY && m_host.contains("cryptonightheavy.");
m_algorithm.setVariant(VARIANT_0);
break;
case 3367:
case 33367:
valid = m_algorithm.algo() == CRYPTONIGHT && m_host.contains("cryptonightv8.");
m_algorithm.setVariant(VARIANT_2);
break;
default:
break;
}
if (!valid) {
m_algorithm.setAlgo(INVALID_ALGO);
}
m_tls = m_port > 33000;
return;
}
if (m_host.contains(".minergate.com")) {
m_keepAlive = false;
bool valid = true;
m_algorithm.setVariant(VARIANT_1);
if (m_host.contains("xmr.pool.")) {
valid = m_algorithm.algo() == CRYPTONIGHT;
m_algorithm.setVariant(m_port == 45700 ? VARIANT_AUTO : VARIANT_0);
}
else if (m_host.contains("aeon.pool.") && m_port == 45690) {
valid = m_algorithm.algo() == CRYPTONIGHT_LITE;
m_algorithm.setVariant(VARIANT_1);
}
if (!valid) {
m_algorithm.setAlgo(INVALID_ALGO);
}
return;
}
if (variantHint != VARIANT_AUTO) {
m_algorithm.setVariant(variantHint);
return;
}
if (m_algorithm.variant() != VARIANT_AUTO) {
return;
}
if (m_algorithm.algo() == CRYPTONIGHT_HEAVY) {
m_algorithm.setVariant(VARIANT_0);
}
else if (m_algorithm.algo() == CRYPTONIGHT_LITE) {
m_algorithm.setVariant(VARIANT_1);
}
# endif
}

View file

@ -1,115 +0,0 @@
/* 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 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
*
* 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_POOL_H
#define XMRIG_POOL_H
#include <vector>
#include "common/crypto/Algorithm.h"
#include "common/utils/c_str.h"
#include "rapidjson/fwd.h"
class Pool
{
public:
constexpr static const char *kDefaultPassword = "x";
constexpr static const char *kDefaultUser = "x";
constexpr static uint16_t kDefaultPort = 3333;
constexpr static int kKeepAliveTimeout = 60;
Pool();
Pool(const char *url);
Pool(const char *host,
uint16_t port,
const char *user = nullptr,
const char *password = nullptr,
int keepAlive = 0,
bool nicehash = false,
bool tls = false
);
inline bool isNicehash() const { return m_nicehash; }
inline bool isTLS() const { return m_tls; }
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
inline const char *fingerprint() const { return m_fingerprint.data(); }
inline const char *host() const { return m_host.data(); }
inline const char *password() const { return !m_password.isNull() ? m_password.data() : kDefaultPassword; }
inline const char *rigId() const { return m_rigId.data(); }
inline const char *url() const { return m_url.data(); }
inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
inline const xmrig::Algorithms &algorithms() const { return m_algorithms; }
inline int keepAlive() const { return m_keepAlive; }
inline uint16_t port() const { return m_port; }
inline void setFingerprint(const char *fingerprint) { m_fingerprint = fingerprint; }
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
inline void setPassword(const char *password) { m_password = password; }
inline void setRigId(const char *rigId) { m_rigId = rigId; }
inline void setTLS(bool tls) { m_tls = tls; }
inline void setUser(const char *user) { m_user = user; }
inline xmrig::Algorithm &algorithm() { return m_algorithm; }
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
inline bool operator==(const Pool &other) const { return isEqual(other); }
bool isCompatible(const xmrig::Algorithm &algorithm) const;
bool isEqual(const Pool &other) const;
bool parse(const char *url);
bool setUserpass(const char *userpass);
rapidjson::Value toJSON(rapidjson::Document &doc) const;
void adjust(const xmrig::Algorithm &algorithm);
void setAlgo(const xmrig::Algorithm &algorithm);
# ifdef APP_DEBUG
void print() const;
# endif
private:
bool parseIPv6(const char *addr);
void adjustVariant(const xmrig::Variant variantHint);
bool m_nicehash;
bool m_tls;
int m_keepAlive;
uint16_t m_port;
xmrig::Algorithm m_algorithm;
xmrig::Algorithms m_algorithms;
xmrig::c_str m_fingerprint;
xmrig::c_str m_host;
xmrig::c_str m_password;
xmrig::c_str m_rigId;
xmrig::c_str m_url;
xmrig::c_str m_user;
};
typedef std::vector<Pool> Pools;
#endif /* XMRIG_POOL_H */

View file

@ -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;
}

View file

@ -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 */

View file

@ -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) {

View file

@ -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,6 +32,9 @@
#include "common/net/Client.h"
namespace xmrig {
class Client::Tls
{
public:
@ -59,4 +63,7 @@ private:
};
} /* namespace xmrig */
#endif /* XMRIG_CLIENT_TLS_H */

View file

@ -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> &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
m_quiet(quiet),
m_retries(retries),
m_retryPause(retryPause),
@ -37,13 +37,24 @@ FailoverStrategy::FailoverStrategy(const std::vector<Pool> &urls, int retryPause
m_index(0),
m_listener(listener)
{
for (const Pool &url : urls) {
add(url);
for (const Pool &pool : pools) {
add(pool);
}
}
FailoverStrategy::~FailoverStrategy()
xmrig::FailoverStrategy::FailoverStrategy(int retryPause, int retries, IStrategyListener *listener, bool quiet) :
m_quiet(quiet),
m_retries(retries),
m_retryPause(retryPause),
m_active(-1),
m_index(0),
m_listener(listener)
{
}
xmrig::FailoverStrategy::~FailoverStrategy()
{
for (Client *client : m_pools) {
client->deleteLater();
@ -51,33 +62,45 @@ FailoverStrategy::~FailoverStrategy()
}
int64_t FailoverStrategy::submit(const JobResult &result)
void xmrig::FailoverStrategy::add(const Pool &pool)
{
Client *client = new Client(static_cast<int>(m_pools.size()), Platform::userAgent(), this);
client->setPool(pool);
client->setRetries(m_retries);
client->setRetryPause(m_retryPause * 1000);
client->setQuiet(m_quiet);
m_pools.push_back(client);
}
int64_t xmrig::FailoverStrategy::submit(const JobResult &result)
{
if (m_active == -1) {
return -1;
}
return m_pools[m_active]->submit(result);
return active()->submit(result);
}
void FailoverStrategy::connect()
void xmrig::FailoverStrategy::connect()
{
m_pools[m_index]->connect();
m_pools[static_cast<size_t>(m_index)]->connect();
}
void FailoverStrategy::resume()
void xmrig::FailoverStrategy::resume()
{
if (!isActive()) {
return;
}
m_listener->onJob(this, m_pools[m_active], m_pools[m_active]->job());
m_listener->onJob(this, active(), active()->job());
}
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 +108,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 +121,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 +129,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;
@ -121,13 +144,13 @@ void FailoverStrategy::onClose(Client *client, int failures)
return;
}
if (m_index == client->id() && (m_pools.size() - m_index) > 1) {
m_pools[++m_index]->connect();
if (m_index == client->id() && (m_pools.size() - static_cast<size_t>(m_index)) > 1) {
m_pools[static_cast<size_t>(++m_index)]->connect();
}
}
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 +158,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,19 +179,7 @@ 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)
{
Client *client = new Client((int) m_pools.size(), Platform::userAgent(), this);
client->setPool(pool);
client->setRetries(m_retries);
client->setRetryPause(m_retryPause * 1000);
client->setQuiet(m_quiet);
m_pools.push_back(client);
}

View file

@ -29,29 +29,34 @@
#include <vector>
#include "base/net/Pool.h"
#include "common/interfaces/IClientListener.h"
#include "common/interfaces/IStrategy.h"
#include "common/net/Pool.h"
namespace xmrig {
class Client;
class IStrategyListener;
class Url;
class FailoverStrategy : public IStrategy, public IClientListener
{
public:
FailoverStrategy(const std::vector<Pool> &urls, 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() override;
void add(const Pool &pool);
public:
inline bool isActive() const override { return m_active >= 0; }
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;
@ -62,7 +67,7 @@ protected:
void onResultAccepted(Client *client, const SubmitResult &result, const char *error) override;
private:
void add(const Pool &pool);
inline Client *active() const { return m_pools[static_cast<size_t>(m_active)]; }
const bool m_quiet;
const int m_retries;
@ -73,4 +78,7 @@ private:
std::vector<Client*> m_pools;
};
} /* namespace xmrig */
#endif /* XMRIG_FAILOVERSTRATEGY_H */

View file

@ -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 *, int)
{
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);
}

View file

@ -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 */

View file

@ -47,7 +47,7 @@ enum PerfAlgo {
PA_CN2, /* cn/2 (Monero) */
PA_CN_HALF, /* cn/half (MSR) */
PA_CN_GPU, /* cn/gpu (RYO) */
PA_CN_WOW, /* cn/wow (WOW) */
PA_CN4, /* cn/4 (Monero) */
PA_CN_LITE, /* cn-lite/1 (AEON) */
PA_CN_HEAVY, /* cn-heavy/0 (LOKI) */
PA_CN_PICO, /* cn-pico/trtl (TRTL) */
@ -89,6 +89,7 @@ enum Variant {
VARIANT_TRTL = 10, // CryptoNight Turtle (TRTL)
VARIANT_GPU = 11, // CryptoNight-GPU (Ryo)
VARIANT_WOW = 12, // CryptoNightR (Wownero)
VARIANT_4 = 13, // CryptoNightR (Monero's variant 4)
VARIANT_MAX
};