Resolved conflicts
This commit is contained in:
commit
d03fb91b0a
82 changed files with 3489 additions and 439 deletions
|
@ -117,9 +117,10 @@ void xmrig::Api::exec(IApiRequest &request)
|
|||
auto &allocator = request.doc().GetAllocator();
|
||||
|
||||
request.accept();
|
||||
request.reply().AddMember("id", StringRef(m_id), allocator);
|
||||
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
|
||||
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
||||
request.reply().AddMember("id", StringRef(m_id), allocator);
|
||||
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
|
||||
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
||||
request.reply().AddMember("restricted", request.isRestricted(), allocator);
|
||||
|
||||
Value features(kArrayType);
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -47,6 +48,8 @@ class String;
|
|||
class Api : public IBaseListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Api)
|
||||
|
||||
Api(Base *base);
|
||||
~Api() override;
|
||||
|
||||
|
|
|
@ -31,8 +31,11 @@
|
|||
xmrig::Console::Console(IConsoleListener *listener)
|
||||
: m_listener(listener)
|
||||
{
|
||||
m_tty = new uv_tty_t;
|
||||
if (!isSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_tty = new uv_tty_t;
|
||||
m_tty->data = this;
|
||||
uv_tty_init(uv_default_loop(), m_tty, 0, 1);
|
||||
|
||||
|
@ -53,6 +56,10 @@ xmrig::Console::~Console()
|
|||
|
||||
void xmrig::Console::stop()
|
||||
{
|
||||
if (!m_tty) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_tty_reset_mode();
|
||||
|
||||
Handle::close(m_tty);
|
||||
|
@ -60,6 +67,13 @@ void xmrig::Console::stop()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Console::isSupported() const
|
||||
{
|
||||
const uv_handle_type type = uv_guess_handle(0);
|
||||
return type == UV_TTY || type == UV_NAMED_PIPE;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Console::onAllocBuffer(uv_handle_t *handle, size_t, uv_buf_t *buf)
|
||||
{
|
||||
auto console = static_cast<Console*>(handle->data);
|
||||
|
|
|
@ -26,9 +26,11 @@
|
|||
#define XMRIG_CONSOLE_H
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
@ -39,18 +41,22 @@ class IConsoleListener;
|
|||
class Console
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Console)
|
||||
|
||||
Console(IConsoleListener *listener);
|
||||
~Console();
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
bool isSupported() const;
|
||||
|
||||
static void onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf);
|
||||
static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
|
||||
|
||||
char m_buf[1];
|
||||
char m_buf[1] = { 0 };
|
||||
IConsoleListener *m_listener;
|
||||
uv_tty_t *m_tty;
|
||||
uv_tty_t *m_tty = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const rapidjson::Value kNullValue;
|
||||
|
@ -36,6 +39,8 @@ static const rapidjson::Value kNullValue;
|
|||
|
||||
bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsBool()) {
|
||||
return i->value.GetBool();
|
||||
|
@ -47,6 +52,8 @@ bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool def
|
|||
|
||||
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsString()) {
|
||||
return i->value.GetString();
|
||||
|
@ -58,6 +65,8 @@ const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key,
|
|||
|
||||
const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const char *key)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsArray()) {
|
||||
return i->value;
|
||||
|
@ -69,6 +78,8 @@ const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const
|
|||
|
||||
const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, const char *key)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsObject()) {
|
||||
return i->value;
|
||||
|
@ -80,6 +91,8 @@ const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, cons
|
|||
|
||||
const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const char *key)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd()) {
|
||||
return i->value;
|
||||
|
@ -91,6 +104,8 @@ const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const
|
|||
|
||||
int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsInt()) {
|
||||
return i->value.GetInt();
|
||||
|
@ -102,6 +117,8 @@ int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaul
|
|||
|
||||
int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsInt64()) {
|
||||
return i->value.GetInt64();
|
||||
|
@ -113,6 +130,8 @@ int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int6
|
|||
|
||||
uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsUint64()) {
|
||||
return i->value.GetUint64();
|
||||
|
@ -124,6 +143,8 @@ uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, ui
|
|||
|
||||
unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto i = obj.FindMember(key);
|
||||
if (i != obj.MemberEnd() && i->value.IsUint()) {
|
||||
return i->value.GetUint();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
#include "base/tools/Handle.h"
|
||||
|
@ -32,9 +32,13 @@
|
|||
#include "base/io/log/Log.h"
|
||||
|
||||
|
||||
xmrig::ConsoleLog::ConsoleLog() :
|
||||
m_stream(nullptr)
|
||||
xmrig::ConsoleLog::ConsoleLog()
|
||||
{
|
||||
if (!isSupported()) {
|
||||
Log::colors = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_tty = new uv_tty_t;
|
||||
|
||||
if (uv_tty_init(uv_default_loop(), m_tty, 1, 0) < 0) {
|
||||
|
@ -66,7 +70,7 @@ xmrig::ConsoleLog::~ConsoleLog()
|
|||
|
||||
void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors)
|
||||
{
|
||||
if (Log::colors != colors) {
|
||||
if (!m_tty || Log::colors != colors) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,12 +90,18 @@ void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool c
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::ConsoleLog::isSupported() const
|
||||
{
|
||||
const uv_handle_type type = uv_guess_handle(1);
|
||||
return type == UV_TTY || type == UV_NAMED_PIPE;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::ConsoleLog::isWritable() const
|
||||
{
|
||||
if (!m_stream || uv_is_writable(m_stream) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uv_handle_type type = uv_guess_handle(1);
|
||||
return type == UV_TTY || type == UV_NAMED_PIPE;
|
||||
return isSupported();
|
||||
}
|
||||
|
|
|
@ -27,11 +27,12 @@
|
|||
#define XMRIG_CONSOLELOG_H
|
||||
|
||||
|
||||
typedef struct uv_stream_s uv_stream_t;
|
||||
typedef struct uv_tty_s uv_tty_t;
|
||||
using uv_stream_t = struct uv_stream_s;
|
||||
using uv_tty_t = struct uv_tty_s;
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/ILogBackend.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -40,6 +41,8 @@ namespace xmrig {
|
|||
class ConsoleLog : public ILogBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(ConsoleLog)
|
||||
|
||||
ConsoleLog();
|
||||
~ConsoleLog() override;
|
||||
|
||||
|
@ -47,10 +50,11 @@ protected:
|
|||
void print(int level, const char *line, size_t offset, size_t size, bool colors) override;
|
||||
|
||||
private:
|
||||
bool isSupported() const;
|
||||
bool isWritable() const;
|
||||
|
||||
uv_stream_t *m_stream;
|
||||
uv_tty_t *m_tty;
|
||||
uv_stream_t *m_stream = nullptr;
|
||||
uv_tty_t *m_tty = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
@ -64,15 +64,16 @@ static const char *kConfigPathV2 = "/2/config";
|
|||
#endif
|
||||
|
||||
|
||||
class xmrig::BasePrivate
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class BasePrivate
|
||||
{
|
||||
public:
|
||||
inline BasePrivate(Process *process) :
|
||||
api(nullptr),
|
||||
config(nullptr),
|
||||
process(process),
|
||||
watcher(nullptr)
|
||||
{}
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(BasePrivate)
|
||||
|
||||
|
||||
inline BasePrivate(Process *process) : config(load(process)) {}
|
||||
|
||||
|
||||
inline ~BasePrivate()
|
||||
|
@ -94,13 +95,33 @@ public:
|
|||
}
|
||||
|
||||
|
||||
inline Config *load()
|
||||
inline void replace(Config *newConfig)
|
||||
{
|
||||
Config *previousConfig = config;
|
||||
config = newConfig;
|
||||
|
||||
for (IBaseListener *listener : listeners) {
|
||||
listener->onConfigChanged(config, previousConfig);
|
||||
}
|
||||
|
||||
delete previousConfig;
|
||||
}
|
||||
|
||||
|
||||
Api *api = nullptr;
|
||||
Config *config = nullptr;
|
||||
std::vector<IBaseListener *> listeners;
|
||||
Watcher *watcher = nullptr;
|
||||
|
||||
|
||||
private:
|
||||
inline Config *load(Process *process)
|
||||
{
|
||||
JsonChain chain;
|
||||
ConfigTransform transform;
|
||||
std::unique_ptr<Config> config;
|
||||
|
||||
transform.load(chain, process, transform);
|
||||
ConfigTransform::load(chain, process, transform);
|
||||
|
||||
if (read(chain, config)) {
|
||||
return config.release();
|
||||
|
@ -122,29 +143,12 @@ public:
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline void replace(Config *newConfig)
|
||||
{
|
||||
Config *previousConfig = config;
|
||||
config = newConfig;
|
||||
|
||||
for (IBaseListener *listener : listeners) {
|
||||
listener->onConfigChanged(config, previousConfig);
|
||||
}
|
||||
|
||||
delete previousConfig;
|
||||
}
|
||||
|
||||
|
||||
Api *api;
|
||||
Config *config;
|
||||
Process *process;
|
||||
std::vector<IBaseListener *> listeners;
|
||||
Watcher *watcher;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Base::Base(Process *process)
|
||||
: d_ptr(new BasePrivate(process))
|
||||
{
|
||||
|
@ -165,14 +169,6 @@ bool xmrig::Base::isReady() const
|
|||
|
||||
int xmrig::Base::init()
|
||||
{
|
||||
d_ptr->config = d_ptr->load();
|
||||
|
||||
if (!d_ptr->config) {
|
||||
LOG_EMERG("No valid configuration found. Exiting.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
d_ptr->api = new Api(this);
|
||||
d_ptr->api->addListener(this);
|
||||
|
@ -184,7 +180,7 @@ int xmrig::Base::init()
|
|||
Platform::setProcessPriority(config()->cpu().priority());
|
||||
# endif
|
||||
|
||||
if (config()->isBackground()) {
|
||||
if (isBackground()) {
|
||||
Log::background = true;
|
||||
}
|
||||
else {
|
||||
|
@ -240,6 +236,12 @@ xmrig::Api *xmrig::Base::api() const
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Base::isBackground() const
|
||||
{
|
||||
return d_ptr->config && d_ptr->config->isBackground();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Base::reload(const rapidjson::Value &json)
|
||||
{
|
||||
JsonReader reader(json);
|
||||
|
@ -247,7 +249,7 @@ bool xmrig::Base::reload(const rapidjson::Value &json)
|
|||
return false;
|
||||
}
|
||||
|
||||
Config *config = new Config();
|
||||
auto config = new Config();
|
||||
if (!config->read(reader, d_ptr->config->fileName())) {
|
||||
delete config;
|
||||
|
||||
|
@ -289,7 +291,7 @@ void xmrig::Base::onFileChanged(const String &fileName)
|
|||
JsonChain chain;
|
||||
chain.addFile(fileName);
|
||||
|
||||
Config *config = new Config();
|
||||
auto config = new Config();
|
||||
|
||||
if (!config->read(chain, chain.fileName())) {
|
||||
LOG_ERR("reloading failed");
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "base/api/interfaces/IApiListener.h"
|
||||
#include "base/kernel/interfaces/IConfigListener.h"
|
||||
#include "base/kernel/interfaces/IWatcherListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
|
@ -45,6 +46,8 @@ class Process;
|
|||
class Base : public IWatcherListener, public IApiListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Base)
|
||||
|
||||
Base(Process *process);
|
||||
~Base() override;
|
||||
|
||||
|
@ -54,6 +57,7 @@ public:
|
|||
virtual void stop();
|
||||
|
||||
Api *api() const;
|
||||
bool isBackground() const;
|
||||
bool reload(const rapidjson::Value &json);
|
||||
Config *config() const;
|
||||
void addListener(IBaseListener *listener);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
|
@ -161,7 +161,7 @@ int xmrig::Entry::exec(const Process &process, Id id)
|
|||
{
|
||||
switch (id) {
|
||||
case Usage:
|
||||
printf(usage);
|
||||
printf("%s\n", usage().c_str());
|
||||
return 0;
|
||||
|
||||
case Version:
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <ctime>
|
||||
#include <uv.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "base/kernel/Process.h"
|
||||
|
@ -55,11 +55,6 @@ xmrig::Process::Process(int argc, char **argv) :
|
|||
}
|
||||
|
||||
|
||||
xmrig::Process::~Process()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Process::location(Location location, const char *fileName) const
|
||||
{
|
||||
constexpr const size_t max = 520;
|
||||
|
|
|
@ -47,7 +47,6 @@ public:
|
|||
# endif
|
||||
|
||||
Process(int argc, char **argv);
|
||||
~Process();
|
||||
|
||||
String location(Location location, const char *fileName = nullptr) const;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -47,15 +47,11 @@ namespace xmrig
|
|||
|
||||
static const char *kAlgo = "algo";
|
||||
static const char *kApi = "api";
|
||||
static const char *kCoin = "coin";
|
||||
static const char *kHttp = "http";
|
||||
static const char *kPools = "pools";
|
||||
|
||||
}
|
||||
|
||||
|
||||
xmrig::BaseTransform::BaseTransform()
|
||||
{
|
||||
}
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTransform &transform)
|
||||
|
@ -68,7 +64,7 @@ void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTrans
|
|||
|
||||
Document doc(kObjectType);
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
key = getopt_long(argc, argv, short_options, options, nullptr);
|
||||
if (key < 0) {
|
||||
break;
|
||||
|
@ -107,6 +103,19 @@ void xmrig::BaseTransform::finalize(rapidjson::Document &doc)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_coin.isValid() && doc.HasMember(kPools)) {
|
||||
auto &pools = doc[kPools];
|
||||
for (Value &pool : pools.GetArray()) {
|
||||
if (!pool.HasMember(kCoin)) {
|
||||
pool.AddMember(StringRef(kCoin), m_coin.toJSON(), allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_http) {
|
||||
set(doc, kHttp, "enabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +131,15 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
}
|
||||
break;
|
||||
|
||||
case IConfig::CoinKey: /* --coin */
|
||||
if (!doc.HasMember(kPools)) {
|
||||
m_coin = arg;
|
||||
}
|
||||
else {
|
||||
return add(doc, kPools, kCoin, arg);
|
||||
}
|
||||
break;
|
||||
|
||||
case IConfig::UserpassKey: /* --userpass */
|
||||
{
|
||||
const char *p = strrchr(arg, ':');
|
||||
|
@ -169,9 +187,11 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
return set(doc, "log-file", arg);
|
||||
|
||||
case IConfig::HttpAccessTokenKey: /* --http-access-token */
|
||||
m_http = true;
|
||||
return set(doc, kHttp, "access-token", arg);
|
||||
|
||||
case IConfig::HttpHostKey: /* --http-host */
|
||||
m_http = true;
|
||||
return set(doc, kHttp, "host", arg);
|
||||
|
||||
case IConfig::ApiWorkerIdKey: /* --api-worker-id */
|
||||
|
@ -228,8 +248,10 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
|||
case IConfig::TlsKey: /* --tls */
|
||||
return add(doc, kPools, "tls", enable);
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::DaemonKey: /* --daemon */
|
||||
return add(doc, kPools, "daemon", enable);
|
||||
# endif
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
case IConfig::NicehashKey: /* --nicehash */
|
||||
|
@ -240,10 +262,12 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
|||
return set(doc, "colors", enable);
|
||||
|
||||
case IConfig::HttpRestrictedKey: /* --http-no-restricted */
|
||||
m_http = true;
|
||||
return set(doc, kHttp, "restricted", enable);
|
||||
|
||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||
return set(doc, kHttp, "enabled", enable);
|
||||
m_http = true;
|
||||
break;
|
||||
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
return set(doc, "dry-run", enable);
|
||||
|
@ -273,13 +297,16 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
|||
return set(doc, "donate-over-proxy", arg);
|
||||
|
||||
case IConfig::HttpPort: /* --http-port */
|
||||
m_http = true;
|
||||
return set(doc, kHttp, "port", arg);
|
||||
|
||||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
return set(doc, "print-time", arg);
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||
return add(doc, kPools, "daemon-poll-interval", arg);
|
||||
# endif
|
||||
|
||||
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||
return set(doc, "bench-algo-time", arg);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
|
||||
#include "base/kernel/interfaces/IConfigTransform.h"
|
||||
#include "crypto/common/Coin.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
|
@ -44,8 +45,6 @@ class Process;
|
|||
class BaseTransform : public IConfigTransform
|
||||
{
|
||||
public:
|
||||
BaseTransform();
|
||||
|
||||
static void load(JsonChain &chain, Process *process, IConfigTransform &transform);
|
||||
|
||||
protected:
|
||||
|
@ -99,11 +98,14 @@ protected:
|
|||
|
||||
protected:
|
||||
Algorithm m_algorithm;
|
||||
Coin m_coin;
|
||||
|
||||
|
||||
private:
|
||||
void transformBoolean(rapidjson::Document &doc, int key, bool enable);
|
||||
void transformUint64(rapidjson::Document &doc, int key, uint64_t arg);
|
||||
|
||||
bool m_http = false;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
enum Keys {
|
||||
// common
|
||||
AlgorithmKey = 'a',
|
||||
CoinKey = 1025,
|
||||
ApiWorkerIdKey = 4002,
|
||||
ApiIdKey = 4005,
|
||||
HttpPort = 4100,
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
BenchAlgoTimeKey = 10002,
|
||||
|
||||
// xmrig cpu
|
||||
CPUKey = 1024,
|
||||
AVKey = 'v',
|
||||
CPUAffinityKey = 1020,
|
||||
DryRunKey = 5000,
|
||||
|
@ -89,6 +91,7 @@ public:
|
|||
AssemblyKey = 1015,
|
||||
RandomXInitKey = 1022,
|
||||
RandomXNumaKey = 1023,
|
||||
CPUMaxThreadsKey = 1026,
|
||||
|
||||
// xmrig amd
|
||||
OclPlatformKey = 1400,
|
||||
|
@ -102,6 +105,7 @@ public:
|
|||
OclMemChunkKey = 1408,
|
||||
OclUnrollKey = 1409,
|
||||
OclCompModeKey = 1410,
|
||||
OclKey = 1411,
|
||||
|
||||
// xmrig-proxy
|
||||
AccessLogFileKey = 'A',
|
||||
|
|
|
@ -338,6 +338,9 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
if (algo) {
|
||||
job.setAlgorithm(algo);
|
||||
}
|
||||
else if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
job.setHeight(Json::getUint64(params, "height"));
|
||||
|
||||
|
@ -430,7 +433,12 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
|||
{
|
||||
if (!algorithm.isValid()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s] Unknown/unsupported algorithm \"%s\" detected, reconnect", url(), algo);
|
||||
if (algo == nullptr) {
|
||||
LOG_ERR("[%s] unknown algorithm, make sure you set \"algo\" or \"coin\" option", url(), algo);
|
||||
}
|
||||
else {
|
||||
LOG_ERR("[%s] unsupported algorithm \"%s\" detected, reconnect", url(), algo);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -440,7 +448,7 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
|||
m_listener->onVerifyAlgorithm(this, algorithm, &ok);
|
||||
|
||||
if (!ok && !isQuiet()) {
|
||||
LOG_ERR("[%s] Incompatible/disabled algorithm \"%s\" detected, reconnect", url(), algorithm.shortName());
|
||||
LOG_ERR("[%s] incompatible/disabled algorithm \"%s\" detected, reconnect", url(), algorithm.shortName());
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
|
@ -225,6 +225,10 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
job.setDiff(Json::getUint64(params, "difficulty"));
|
||||
job.setId(blocktemplate.data() + blocktemplate.size() - 32);
|
||||
|
||||
if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
m_job = std::move(job);
|
||||
m_blocktemplate = std::move(blocktemplate);
|
||||
m_prevHash = Json::getString(params, "prev_hash");
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
inline uint8_t fixedByte() const { return *(m_blob + 42); }
|
||||
inline uint8_t index() const { return m_index; }
|
||||
inline void reset() { m_size = 0; m_diff = 0; }
|
||||
inline void setAlgorithm(const Algorithm::Id id) { m_algorithm = id; }
|
||||
inline void setAlgorithm(const char *algo) { m_algorithm = algo; }
|
||||
inline void setClientId(const String &id) { m_clientId = id; }
|
||||
inline void setHeight(uint64_t height) { m_height = height; }
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
namespace xmrig {
|
||||
|
||||
static const char *kAlgo = "algo";
|
||||
static const char *kCoin = "coin";
|
||||
static const char *kDaemon = "daemon";
|
||||
static const char *kDaemonPollInterval = "daemon-poll-interval";
|
||||
static const char *kEnabled = "enabled";
|
||||
|
@ -120,6 +121,7 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
|
|||
m_fingerprint = Json::getString(object, kFingerprint);
|
||||
m_pollInterval = Json::getUint64(object, kDaemonPollInterval, kDefaultPollInterval);
|
||||
m_algorithm = Json::getString(object, kAlgo);
|
||||
m_coin = Json::getString(object, kCoin);
|
||||
|
||||
m_flags.set(FLAG_ENABLED, Json::getBool(object, kEnabled, true));
|
||||
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash));
|
||||
|
@ -172,7 +174,7 @@ bool xmrig::Pool::isEnabled() const
|
|||
}
|
||||
# endif
|
||||
|
||||
if (isDaemon() && !algorithm().isValid()) {
|
||||
if (isDaemon() && (!algorithm().isValid() && !coin().isValid())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -186,6 +188,7 @@ bool xmrig::Pool::isEqual(const Pool &other) const
|
|||
&& m_keepAlive == other.m_keepAlive
|
||||
&& m_port == other.m_port
|
||||
&& m_algorithm == other.m_algorithm
|
||||
&& m_coin == other.m_coin
|
||||
&& m_fingerprint == other.m_fingerprint
|
||||
&& m_host == other.m_host
|
||||
&& m_password == other.m_password
|
||||
|
@ -268,6 +271,7 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const
|
|||
Value obj(kObjectType);
|
||||
|
||||
obj.AddMember(StringRef(kAlgo), m_algorithm.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kCoin), m_coin.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kUrl), m_url.toJSON(), allocator);
|
||||
obj.AddMember(StringRef(kUser), m_user.toJSON(), allocator);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
#include "base/tools/String.h"
|
||||
#include "crypto/common/Algorithm.h"
|
||||
#include "crypto/common/Coin.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
|
@ -74,6 +74,7 @@ public:
|
|||
inline bool isTLS() const { return m_flags.test(FLAG_TLS); }
|
||||
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
|
||||
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||
inline const Coin &coin() const { return m_coin; }
|
||||
inline const String &fingerprint() const { return m_fingerprint; }
|
||||
inline const String &host() const { return m_host; }
|
||||
inline const String &password() const { return !m_password.isNull() ? m_password : kDefaultPassword; }
|
||||
|
@ -107,6 +108,7 @@ private:
|
|||
bool parseIPv6(const char *addr);
|
||||
|
||||
Algorithm m_algorithm;
|
||||
Coin m_coin;
|
||||
int m_keepAlive;
|
||||
std::bitset<FLAG_MAX> m_flags;
|
||||
String m_fingerprint;
|
||||
|
|
|
@ -138,11 +138,12 @@ void xmrig::Pools::print() const
|
|||
{
|
||||
size_t i = 1;
|
||||
for (const Pool &pool : m_data) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") CSI "1;%dm%s" CLEAR " algo " WHITE_BOLD("%s"),
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("POOL #%-7zu") CSI "1;%dm%s" CLEAR " %s " WHITE_BOLD("%s"),
|
||||
i,
|
||||
(pool.isEnabled() ? (pool.isTLS() ? 32 : 36) : 31),
|
||||
pool.url().data(),
|
||||
pool.algorithm().isValid() ? pool.algorithm().shortName() : "auto"
|
||||
pool.coin().isValid() ? "coin" : "algo",
|
||||
pool.coin().isValid() ? pool.coin().name() : (pool.algorithm().isValid() ? pool.algorithm().shortName() : "auto")
|
||||
);
|
||||
|
||||
i++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue