mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-24 21:32:47 -05:00
Draft merge
This commit is contained in:
@@ -27,72 +27,28 @@
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "common/config/ConfigLoader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "common/interfaces/IControllerListener.h"
|
||||
#include "common/log/ConsoleLog.h"
|
||||
#include "common/log/FileLog.h"
|
||||
#include "common/log/Log.h"
|
||||
#include "common/Platform.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "net/Network.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
# include "common/log/SysLog.h"
|
||||
#endif
|
||||
|
||||
|
||||
class xmrig::ControllerPrivate
|
||||
{
|
||||
public:
|
||||
inline ControllerPrivate(Process *process) :
|
||||
config(nullptr),
|
||||
network(nullptr),
|
||||
process(process)
|
||||
{}
|
||||
|
||||
|
||||
inline ~ControllerPrivate()
|
||||
{
|
||||
delete network;
|
||||
delete config;
|
||||
}
|
||||
|
||||
|
||||
Config *config;
|
||||
Network *network;
|
||||
Process *process;
|
||||
std::vector<IControllerListener *> listeners;
|
||||
};
|
||||
|
||||
|
||||
xmrig::Controller::Controller(Process *process)
|
||||
: d_ptr(new ControllerPrivate(process))
|
||||
xmrig::Controller::Controller(Process *process) :
|
||||
Base(process),
|
||||
m_network(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::Controller::~Controller()
|
||||
{
|
||||
ConfigLoader::release();
|
||||
|
||||
delete d_ptr;
|
||||
delete m_network;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Controller::isReady() const
|
||||
{
|
||||
return d_ptr->config && d_ptr->network;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Config *xmrig::Controller::config() const
|
||||
{
|
||||
assert(d_ptr->config != nullptr);
|
||||
|
||||
return d_ptr->config;
|
||||
return Base::isReady() && m_network;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,73 +56,38 @@ int xmrig::Controller::init()
|
||||
{
|
||||
Cpu::init();
|
||||
|
||||
// init pconfig global pointer to config
|
||||
pconfig = d_ptr->config = Config::load(d_ptr->process, this);
|
||||
if (!d_ptr->config) {
|
||||
return 1;
|
||||
const int rc = Base::init();
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
Log::init();
|
||||
Platform::init(config()->userAgent());
|
||||
Platform::setProcessPriority(d_ptr->config->priority());
|
||||
|
||||
if (!config()->isBackground()) {
|
||||
Log::add(new ConsoleLog(this));
|
||||
}
|
||||
|
||||
if (config()->logFile()) {
|
||||
Log::add(new FileLog(this, config()->logFile()));
|
||||
}
|
||||
|
||||
# ifdef HAVE_SYSLOG_H
|
||||
if (config()->isSyslog()) {
|
||||
Log::add(new SysLog());
|
||||
}
|
||||
# endif
|
||||
|
||||
if (strstr(config()->pools().data()[0].host(), "moneroocean.stream")) config()->setDonateLevel(0);
|
||||
|
||||
d_ptr->network = new Network(this);
|
||||
m_network = new Network(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::start()
|
||||
{
|
||||
Base::start();
|
||||
|
||||
network()->connect();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::stop()
|
||||
{
|
||||
Base::stop();
|
||||
|
||||
delete m_network;
|
||||
m_network = nullptr;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Network *xmrig::Controller::network() const
|
||||
{
|
||||
assert(d_ptr->network != nullptr);
|
||||
assert(m_network != nullptr);
|
||||
|
||||
return d_ptr->network;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::addListener(IControllerListener *listener)
|
||||
{
|
||||
d_ptr->listeners.push_back(listener);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::save()
|
||||
{
|
||||
if (!config()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (d_ptr->config->isShouldSave()) {
|
||||
d_ptr->config->save();
|
||||
}
|
||||
|
||||
ConfigLoader::watch(d_ptr->config);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::onNewConfig(IConfig *config)
|
||||
{
|
||||
Config *previousConfig = d_ptr->config;
|
||||
d_ptr->config = static_cast<Config*>(config);
|
||||
|
||||
for (xmrig::IControllerListener *listener : d_ptr->listeners) {
|
||||
listener->onConfigChanged(d_ptr->config, previousConfig);
|
||||
}
|
||||
|
||||
delete previousConfig;
|
||||
return m_network;
|
||||
}
|
||||
|
||||
@@ -26,44 +26,34 @@
|
||||
#define XMRIG_CONTROLLER_H
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IConfigListener.h"
|
||||
|
||||
|
||||
class StatsData;
|
||||
#include "base/kernel/Base.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Config;
|
||||
class ControllerPrivate;
|
||||
class IControllerListener;
|
||||
class Network;
|
||||
class Process;
|
||||
|
||||
|
||||
class Controller : public IConfigListener
|
||||
class Controller : public Base
|
||||
{
|
||||
public:
|
||||
Controller(Process *process);
|
||||
~Controller() override;
|
||||
|
||||
bool isReady() const;
|
||||
Config *config() const;
|
||||
int init();
|
||||
Network *network() const;
|
||||
void addListener(IControllerListener *listener);
|
||||
void save();
|
||||
bool isReady() const override;
|
||||
int init() override;
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
protected:
|
||||
void onNewConfig(IConfig *config) override;
|
||||
Network *network() const;
|
||||
|
||||
private:
|
||||
ControllerPrivate *d_ptr;
|
||||
Network *m_network;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_CONTROLLER_H */
|
||||
|
||||
337
src/core/config/Config.cpp
Normal file
337
src/core/config/Config.cpp
Normal file
@@ -0,0 +1,337 @@
|
||||
/* 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>
|
||||
* 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
|
||||
* 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 <algorithm>
|
||||
#include <string.h>
|
||||
#include <uv.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "crypto/Asm.h"
|
||||
#include "crypto/CryptoNight_constants.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
#include "workers/CpuThread.h"
|
||||
|
||||
// for usage in Client::login to get_algo_perf
|
||||
namespace xmrig {
|
||||
Config* pconfig = nullptr;
|
||||
};
|
||||
|
||||
static char affinity_tmp[20] = { 0 };
|
||||
|
||||
|
||||
xmrig::Config::Config() :
|
||||
m_aesMode(AES_AUTO),
|
||||
m_algoVariant(AV_AUTO),
|
||||
m_assembly(ASM_AUTO),
|
||||
m_hugePages(true),
|
||||
m_safe(false),
|
||||
m_shouldSave(false),
|
||||
m_maxCpuUsage(100),
|
||||
m_priority(-1)
|
||||
{
|
||||
// not defined algo performance is considered to be 0
|
||||
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
|
||||
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
|
||||
m_algo_perf[pa] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||
{
|
||||
if (!BaseConfig::read(reader, fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hugePages = reader.getBool("huge-pages", true);
|
||||
m_safe = reader.getBool("safe");
|
||||
|
||||
setAesMode(reader.getValue("hw-aes"));
|
||||
setAlgoVariant(reader.getInt("av"));
|
||||
setMaxCpuUsage(reader.getInt("max-cpu-usage", 100));
|
||||
setPriority(reader.getInt("cpu-priority", -1));
|
||||
setThreads(reader.getValue("threads"));
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
setAssembly(reader.getValue("asm"));
|
||||
# endif
|
||||
|
||||
return finalize();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
doc.SetObject();
|
||||
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("algo", StringRef(algorithm().name()), allocator);
|
||||
|
||||
Value api(kObjectType);
|
||||
api.AddMember("id", m_apiId.toJSON(), allocator);
|
||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
||||
doc.AddMember("api", api, allocator);
|
||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("av", algoVariant(), allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
|
||||
if (affinity() != -1L) {
|
||||
snprintf(affinity_tmp, sizeof(affinity_tmp) - 1, "0x%" PRIX64, affinity());
|
||||
doc.AddMember("cpu-affinity", StringRef(affinity_tmp), allocator);
|
||||
}
|
||||
else {
|
||||
doc.AddMember("cpu-affinity", kNullType, allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("cpu-priority", priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
|
||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
||||
doc.AddMember("huge-pages", isHugePages(), allocator);
|
||||
doc.AddMember("hw-aes", m_aesMode == AES_AUTO ? Value(kNullType) : Value(m_aesMode == AES_HW), allocator);
|
||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
||||
doc.AddMember("max-cpu-usage", m_maxCpuUsage, allocator);
|
||||
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
||||
doc.AddMember("print-time", printTime(), allocator);
|
||||
doc.AddMember("retries", m_pools.retries(), allocator);
|
||||
doc.AddMember("retry-pause", m_pools.retryPause(), allocator);
|
||||
doc.AddMember("safe", m_safe, allocator);
|
||||
|
||||
// save extended "threads" based on m_threads
|
||||
Value threads(kObjectType);
|
||||
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||
Value key(xmrig::Algorithm::perfAlgoName(xmrig::Algorithm(algo).perf_algo()), allocator);
|
||||
if (threadsMode(algo) != Simple) {
|
||||
Value threads2(kArrayType);
|
||||
for (const IThread *thread : m_threads[algo].list) {
|
||||
threads2.PushBack(thread->toConfig(doc), allocator);
|
||||
}
|
||||
|
||||
threads.AddMember(key, threads2, allocator);
|
||||
}
|
||||
else {
|
||||
threads.AddMember(key, threadsCount(), allocator);
|
||||
}
|
||||
}
|
||||
doc.AddMember("threads", threads, allocator);
|
||||
|
||||
// save "algo-perf" based on m_algo_perf
|
||||
Value algo_perf(kObjectType);
|
||||
for (int a = 0; a != xmrig::PerfAlgo::PA_MAX; ++ a) {
|
||||
const xmrig::PerfAlgo pa = static_cast<xmrig::PerfAlgo>(a);
|
||||
Value key(xmrig::Algorithm::perfAlgoName(pa), allocator);
|
||||
algo_perf.AddMember(key, Value(m_algo_perf[pa]), allocator);
|
||||
}
|
||||
doc.AddMember("algo-perf", algo_perf, allocator);
|
||||
|
||||
doc.AddMember("calibrate-algo", isCalibrateAlgo(), allocator);
|
||||
doc.AddMember("calibrate-algo-time", calibrateAlgoTime(), allocator);
|
||||
|
||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember("syslog", isSyslog(), allocator);
|
||||
doc.AddMember("watch", m_watch, allocator);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::finalize()
|
||||
{
|
||||
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||
if (!m_threads[algo].cpu.empty()) {
|
||||
m_threads[algo].mode = Advanced;
|
||||
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::info()->hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
|
||||
|
||||
for (size_t i = 0; i < m_threads[algo].cpu.size(); ++i) {
|
||||
m_threads[algo].list.push_back(CpuThread::createFromData(i, m_algorithm.algo(), m_threads[algo].cpu[i], m_priority, softAES));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const AlgoVariant av = getAlgoVariant();
|
||||
m_threads[algo].mode = m_threads[algo].count ? Simple : Automatic;
|
||||
|
||||
const Variant v = m_algorithm.variant();
|
||||
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo(), v) / 1024;
|
||||
|
||||
if (!m_threads[algo].count) {
|
||||
m_threads[algo].count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
|
||||
}
|
||||
else if (m_safe) {
|
||||
const size_t count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
|
||||
if (m_threads[algo].count > count) {
|
||||
m_threads[algo].count = count;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_threads[algo].count; ++i) {
|
||||
m_threads[algo].list.push_back(CpuThread::createFromAV(i, m_algorithm.algo(), av, m_threads[algo].mask, m_priority, m_assembly));
|
||||
}
|
||||
|
||||
m_shouldSave = m_shouldSave || m_threads[algo].mode == Automatic;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setAesMode(const rapidjson::Value &aesMode)
|
||||
{
|
||||
if (aesMode.IsBool()) {
|
||||
m_aesMode = aesMode.GetBool() ? AES_HW : AES_SOFT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setAlgoVariant(int av)
|
||||
{
|
||||
if (av >= AV_AUTO && av < AV_MAX) {
|
||||
m_algoVariant = static_cast<AlgoVariant>(av);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setMaxCpuUsage(int max)
|
||||
{
|
||||
if (max > 0 && max <= 100) {
|
||||
m_maxCpuUsage = max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setPriority(int priority)
|
||||
{
|
||||
if (priority >= 0 && priority <= 5) {
|
||||
m_priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// parse specific perf algo (or generic) threads config
|
||||
void xmrig::Config::setThread(const rapidjson::Value &threads, const xmrig::Algo algo)
|
||||
{
|
||||
m_threads[algo].cpu.clear();
|
||||
|
||||
for (const rapidjson::Value &value : threads.GetArray()) {
|
||||
if (!value.IsObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.HasMember("low_power_mode")) {
|
||||
auto data = CpuThread::parse(value);
|
||||
|
||||
if (data.valid) {
|
||||
m_threads[algo].cpu.push_back(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setThreads(const rapidjson::Value &threads)
|
||||
{
|
||||
if (threads.IsArray()) {
|
||||
setThread(threads, m_algorithm.algo());
|
||||
}
|
||||
else if (threads.IsObject()) {
|
||||
// parse new specific perf algo threads
|
||||
for (int a = 0; a != xmrig::Algo::ALGO_MAX; ++ a) {
|
||||
const xmrig::Algo algo = static_cast<xmrig::Algo>(a);
|
||||
const rapidjson::Value &threads2 = threads[xmrig::Algorithm::perfAlgoName(xmrig::Algorithm(algo).perf_algo())];
|
||||
if (threads2.IsArray()) {
|
||||
setThread(threads2, algo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (threads.IsUint()) {
|
||||
const unsigned count = threads.GetUint();
|
||||
if (count < 1024) {
|
||||
m_threads[m_algorithm.algo()].count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) {
|
||||
return getAlgoVariantLite();
|
||||
}
|
||||
# endif
|
||||
|
||||
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? AV_SINGLE : AV_SINGLE_SOFT;
|
||||
}
|
||||
|
||||
if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
}
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
|
||||
{
|
||||
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? AV_DOUBLE : AV_DOUBLE_SOFT;
|
||||
}
|
||||
|
||||
if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
}
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_ASM
|
||||
void xmrig::Config::setAssembly(const rapidjson::Value &assembly)
|
||||
{
|
||||
m_assembly = Asm::parse(assembly);
|
||||
}
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "common/config/CommonConfig.h"
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "common/xmrig.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
#include "workers/CpuThread.h"
|
||||
@@ -56,7 +56,7 @@ class Process;
|
||||
* api/worker-id
|
||||
* pools/
|
||||
*/
|
||||
class Config : public CommonConfig
|
||||
class Config : public BaseConfig
|
||||
{
|
||||
public:
|
||||
enum ThreadsMode {
|
||||
@@ -68,15 +68,15 @@ public:
|
||||
|
||||
Config();
|
||||
|
||||
bool reload(const char *json);
|
||||
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
inline AesMode aesMode() const { return m_aesMode; }
|
||||
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
||||
inline Assembly assembly() const { return m_assembly; }
|
||||
inline bool isHugePages() const { return m_hugePages; }
|
||||
inline bool isShouldSave() const { return m_shouldSave && isAutoSave(); }
|
||||
|
||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade) && isAutoSave(); }
|
||||
inline int priority() const { return m_priority; }
|
||||
|
||||
// access to m_threads taking into accoun that it is now separated for each perf algo
|
||||
@@ -97,25 +97,25 @@ public:
|
||||
inline float get_algo_perf(const xmrig::PerfAlgo pa) const { return m_algo_perf[pa]; }
|
||||
inline void set_algo_perf(const xmrig::PerfAlgo pa, const float value) { m_algo_perf[pa] = value; }
|
||||
|
||||
static Config *load(Process *process, IConfigListener *listener);
|
||||
|
||||
protected:
|
||||
bool finalize() override;
|
||||
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;
|
||||
// parse specific perf algo (or generic) threads config
|
||||
void parseThreadsJSON(const rapidjson::Value &threads, xmrig::Algo);
|
||||
|
||||
private:
|
||||
bool parseInt(int key, int arg);
|
||||
bool finalize();
|
||||
void setAesMode(const rapidjson::Value &aesMode);
|
||||
void setAlgoVariant(int av);
|
||||
void setMaxCpuUsage(int max);
|
||||
void setPriority(int priority);
|
||||
// parse specific perf algo (or generic) threads config
|
||||
void setThread(const rapidjson::Value &threads, xmrig::Algo);
|
||||
void setThreads(const rapidjson::Value &threads);
|
||||
|
||||
AlgoVariant getAlgoVariant() const;
|
||||
# ifndef XMRIG_NO_AEON
|
||||
AlgoVariant getAlgoVariantLite() const;
|
||||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
void setAssembly(const rapidjson::Value &assembly);
|
||||
# endif
|
||||
|
||||
|
||||
struct Threads
|
||||
{
|
||||
287
src/core/config/Config.new.cpp
Normal file
287
src/core/config/Config.new.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <uv.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "crypto/Asm.h"
|
||||
#include "crypto/CryptoNight_constants.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
#include "workers/CpuThread.h"
|
||||
|
||||
|
||||
static char affinity_tmp[20] = { 0 };
|
||||
|
||||
|
||||
xmrig::Config::Config() :
|
||||
m_aesMode(AES_AUTO),
|
||||
m_algoVariant(AV_AUTO),
|
||||
m_assembly(ASM_AUTO),
|
||||
m_hugePages(true),
|
||||
m_safe(false),
|
||||
m_shouldSave(false),
|
||||
m_maxCpuUsage(100),
|
||||
m_priority(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||
{
|
||||
if (!BaseConfig::read(reader, fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hugePages = reader.getBool("huge-pages", true);
|
||||
m_safe = reader.getBool("safe");
|
||||
|
||||
setAesMode(reader.getValue("hw-aes"));
|
||||
setAlgoVariant(reader.getInt("av"));
|
||||
setMaxCpuUsage(reader.getInt("max-cpu-usage", 100));
|
||||
setPriority(reader.getInt("cpu-priority", -1));
|
||||
setThreads(reader.getValue("threads"));
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
setAssembly(reader.getValue("asm"));
|
||||
# endif
|
||||
|
||||
return finalize();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
doc.SetObject();
|
||||
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("algo", StringRef(algorithm().name()), allocator);
|
||||
|
||||
Value api(kObjectType);
|
||||
api.AddMember("id", m_apiId.toJSON(), allocator);
|
||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
||||
doc.AddMember("api", api, allocator);
|
||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("av", algoVariant(), allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
|
||||
if (affinity() != -1L) {
|
||||
snprintf(affinity_tmp, sizeof(affinity_tmp) - 1, "0x%" PRIX64, affinity());
|
||||
doc.AddMember("cpu-affinity", StringRef(affinity_tmp), allocator);
|
||||
}
|
||||
else {
|
||||
doc.AddMember("cpu-affinity", kNullType, allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("cpu-priority", priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
|
||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
||||
doc.AddMember("huge-pages", isHugePages(), allocator);
|
||||
doc.AddMember("hw-aes", m_aesMode == AES_AUTO ? Value(kNullType) : Value(m_aesMode == AES_HW), allocator);
|
||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
||||
doc.AddMember("max-cpu-usage", m_maxCpuUsage, allocator);
|
||||
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
||||
doc.AddMember("print-time", printTime(), allocator);
|
||||
doc.AddMember("retries", m_pools.retries(), allocator);
|
||||
doc.AddMember("retry-pause", m_pools.retryPause(), allocator);
|
||||
doc.AddMember("safe", m_safe, allocator);
|
||||
|
||||
if (threadsMode() != Simple) {
|
||||
Value threads(kArrayType);
|
||||
|
||||
for (const IThread *thread : m_threads.list) {
|
||||
threads.PushBack(thread->toConfig(doc), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("threads", threads, allocator);
|
||||
}
|
||||
else {
|
||||
doc.AddMember("threads", threadsCount(), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember("syslog", isSyslog(), allocator);
|
||||
doc.AddMember("watch", m_watch, allocator);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::finalize()
|
||||
{
|
||||
if (!m_threads.cpu.empty()) {
|
||||
m_threads.mode = Advanced;
|
||||
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::info()->hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
|
||||
|
||||
for (size_t i = 0; i < m_threads.cpu.size(); ++i) {
|
||||
m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm.algo(), m_threads.cpu[i], m_priority, softAES));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const AlgoVariant av = getAlgoVariant();
|
||||
m_threads.mode = m_threads.count ? Simple : Automatic;
|
||||
|
||||
const Variant v = m_algorithm.variant();
|
||||
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo(), v) / 1024;
|
||||
|
||||
if (!m_threads.count) {
|
||||
m_threads.count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
|
||||
}
|
||||
else if (m_safe) {
|
||||
const size_t count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
|
||||
if (m_threads.count > count) {
|
||||
m_threads.count = count;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_threads.count; ++i) {
|
||||
m_threads.list.push_back(CpuThread::createFromAV(i, m_algorithm.algo(), av, m_threads.mask, m_priority, m_assembly));
|
||||
}
|
||||
|
||||
m_shouldSave = m_threads.mode == Automatic;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setAesMode(const rapidjson::Value &aesMode)
|
||||
{
|
||||
if (aesMode.IsBool()) {
|
||||
m_aesMode = aesMode.GetBool() ? AES_HW : AES_SOFT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setAlgoVariant(int av)
|
||||
{
|
||||
if (av >= AV_AUTO && av < AV_MAX) {
|
||||
m_algoVariant = static_cast<AlgoVariant>(av);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setMaxCpuUsage(int max)
|
||||
{
|
||||
if (max > 0 && max <= 100) {
|
||||
m_maxCpuUsage = max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setPriority(int priority)
|
||||
{
|
||||
if (priority >= 0 && priority <= 5) {
|
||||
m_priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setThreads(const rapidjson::Value &threads)
|
||||
{
|
||||
if (threads.IsArray()) {
|
||||
m_threads.cpu.clear();
|
||||
|
||||
for (const rapidjson::Value &value : threads.GetArray()) {
|
||||
if (!value.IsObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.HasMember("low_power_mode")) {
|
||||
auto data = CpuThread::parse(value);
|
||||
|
||||
if (data.valid) {
|
||||
m_threads.cpu.push_back(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (threads.IsUint()) {
|
||||
const unsigned count = threads.GetUint();
|
||||
if (count < 1024) {
|
||||
m_threads.count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) {
|
||||
return getAlgoVariantLite();
|
||||
}
|
||||
# endif
|
||||
|
||||
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? AV_SINGLE : AV_SINGLE_SOFT;
|
||||
}
|
||||
|
||||
if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
}
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
|
||||
{
|
||||
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? AV_DOUBLE : AV_DOUBLE_SOFT;
|
||||
}
|
||||
|
||||
if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
}
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_ASM
|
||||
void xmrig::Config::setAssembly(const rapidjson::Value &assembly)
|
||||
{
|
||||
m_assembly = Asm::parse(assembly);
|
||||
}
|
||||
#endif
|
||||
49
src/core/config/ConfigTransform.cpp
Normal file
49
src/core/config/ConfigTransform.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "core/config/ConfigTransform.h"
|
||||
#include "base/kernel/interfaces/IConfig.h"
|
||||
|
||||
|
||||
xmrig::ConfigTransform::ConfigTransform()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const char *arg)
|
||||
{
|
||||
BaseTransform::transform(doc, key, arg);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigTransform::transformBoolean(rapidjson::Document &doc, int key, bool enable)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigTransform::transformUint64(rapidjson::Document &doc, int key, uint64_t arg)
|
||||
{
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
* 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 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
|
||||
@@ -20,31 +21,31 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIGCREATOR_H__
|
||||
#define __CONFIGCREATOR_H__
|
||||
#ifndef XMRIG_CONFIGTRANSFORM_H
|
||||
#define XMRIG_CONFIGTRANSFORM_H
|
||||
|
||||
|
||||
#include "common/interfaces/IConfigCreator.h"
|
||||
#include "core/Config.h"
|
||||
#include "base/kernel/config/BaseTransform.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IConfig;
|
||||
|
||||
|
||||
class ConfigCreator : public IConfigCreator
|
||||
class ConfigTransform : public BaseTransform
|
||||
{
|
||||
public:
|
||||
inline IConfig *create() const override
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
ConfigTransform();
|
||||
|
||||
protected:
|
||||
void transform(rapidjson::Document &doc, int key, const char *arg) override;
|
||||
|
||||
private:
|
||||
void transformBoolean(rapidjson::Document &doc, int key, bool enable);
|
||||
void transformUint64(rapidjson::Document &doc, int key, uint64_t arg);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif // __CONFIGCREATOR_H__
|
||||
#endif /* XMRIG_CONFIGTRANSFORM_H */
|
||||
@@ -22,8 +22,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CONFIGLOADER_DEFAULT_H
|
||||
#define XMRIG_CONFIGLOADER_DEFAULT_H
|
||||
#ifndef XMRIG_CONFIG_DEFAULT_H
|
||||
#define XMRIG_CONFIG_DEFAULT_H
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -35,11 +35,14 @@ R"===(
|
||||
{
|
||||
"algo": "cryptonight",
|
||||
"api": {
|
||||
"id": null,
|
||||
"worker-id": null
|
||||
},
|
||||
"http": {
|
||||
"enabled": false,
|
||||
"host": "127.0.0.1",
|
||||
"port": 0,
|
||||
"access-token": null,
|
||||
"id": null,
|
||||
"worker-id": null,
|
||||
"ipv6": false,
|
||||
"restricted": true
|
||||
},
|
||||
"asm": true,
|
||||
@@ -50,6 +53,7 @@ R"===(
|
||||
"cpu-affinity": null,
|
||||
"cpu-priority": null,
|
||||
"donate-level": 5,
|
||||
"donate-over-proxy": 1,
|
||||
"huge-pages": true,
|
||||
"hw-aes": null,
|
||||
"log-file": null,
|
||||
@@ -63,8 +67,11 @@ R"===(
|
||||
"nicehash": false,
|
||||
"keepalive": false,
|
||||
"variant": -1,
|
||||
"enabled": true,
|
||||
"tls": false,
|
||||
"tls-fingerprint": null
|
||||
"tls-fingerprint": null,
|
||||
"daemon": false,
|
||||
"daemon-poll-interval": 1000
|
||||
}
|
||||
],
|
||||
"print-time": 60,
|
||||
@@ -73,12 +80,14 @@ R"===(
|
||||
"safe": false,
|
||||
"threads": null,
|
||||
"user-agent": null,
|
||||
"watch": false
|
||||
"syslog": false,
|
||||
"watch": true
|
||||
}
|
||||
)===";
|
||||
#endif
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
} // namespace xmrig
|
||||
|
||||
#endif /* XMRIG_CONFIGLOADER_DEFAULT_H */
|
||||
|
||||
#endif /* XMRIG_CONFIG_DEFAULT_H */
|
||||
127
src/core/config/Config_platform.h
Normal file
127
src/core/config/Config_platform.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CONFIG_PLATFORM_H
|
||||
#define XMRIG_CONFIG_PLATFORM_H
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include "getopt/getopt.h"
|
||||
#else
|
||||
# include <getopt.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IConfig.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char short_options[] = "a:c:kBp:Px:r:R:s:t:T:o:u:O:v:l:S";
|
||||
|
||||
|
||||
static const option options[] = {
|
||||
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
|
||||
{ "api-worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
|
||||
{ "api-id", 1, nullptr, IConfig::ApiIdKey },
|
||||
{ "http-enabled", 0, nullptr, IConfig::HttpEnabledKey },
|
||||
{ "http-host", 1, nullptr, IConfig::HttpHostKey },
|
||||
{ "http-access-token", 1, nullptr, IConfig::HttpAccessTokenKey },
|
||||
{ "http-port", 1, nullptr, IConfig::HttpPort },
|
||||
{ "http-no-restricted", 0, nullptr, IConfig::HttpRestrictedKey },
|
||||
{ "av", 1, nullptr, IConfig::AVKey },
|
||||
{ "background", 0, nullptr, IConfig::BackgroundKey },
|
||||
{ "config", 1, nullptr, IConfig::ConfigKey },
|
||||
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
|
||||
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
|
||||
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
|
||||
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
|
||||
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
|
||||
{ "keepalive", 0, nullptr, IConfig::KeepAliveKey },
|
||||
{ "log-file", 1, nullptr, IConfig::LogFileKey },
|
||||
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
|
||||
{ "nicehash", 0, nullptr, IConfig::NicehashKey },
|
||||
{ "no-color", 0, nullptr, IConfig::ColorKey },
|
||||
{ "no-huge-pages", 0, nullptr, IConfig::HugePagesKey },
|
||||
{ "variant", 1, nullptr, IConfig::VariantKey },
|
||||
{ "pass", 1, nullptr, IConfig::PasswordKey },
|
||||
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
|
||||
{ "retries", 1, nullptr, IConfig::RetriesKey },
|
||||
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
|
||||
{ "safe", 0, nullptr, IConfig::SafeKey },
|
||||
{ "syslog", 0, nullptr, IConfig::SyslogKey },
|
||||
{ "threads", 1, nullptr, IConfig::ThreadsKey },
|
||||
{ "url", 1, nullptr, IConfig::UrlKey },
|
||||
{ "user", 1, nullptr, IConfig::UserKey },
|
||||
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
|
||||
{ "userpass", 1, nullptr, IConfig::UserpassKey },
|
||||
{ "rig-id", 1, nullptr, IConfig::RigIdKey },
|
||||
{ "tls", 0, nullptr, IConfig::TlsKey },
|
||||
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
|
||||
{ "asm", 1, nullptr, IConfig::AssemblyKey },
|
||||
{ "daemon", 0, nullptr, IConfig::DaemonKey },
|
||||
{ "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey },
|
||||
|
||||
# ifdef XMRIG_DEPRECATED
|
||||
{ "api-port", 1, nullptr, IConfig::ApiPort },
|
||||
{ "api-access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
|
||||
{ "api-no-restricted", 0, nullptr, IConfig::ApiRestrictedKey },
|
||||
{ "api-ipv6", 0, nullptr, IConfig::ApiIPv6Key },
|
||||
# endif
|
||||
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
|
||||
static struct option const config_options[] = {
|
||||
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
|
||||
{ "av", 1, nullptr, IConfig::AVKey },
|
||||
{ "background", 0, nullptr, IConfig::BackgroundKey },
|
||||
{ "colors", 0, nullptr, IConfig::ColorKey },
|
||||
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
|
||||
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
|
||||
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
|
||||
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
|
||||
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
|
||||
{ "huge-pages", 0, nullptr, IConfig::HugePagesKey },
|
||||
{ "log-file", 1, nullptr, IConfig::LogFileKey },
|
||||
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
|
||||
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
|
||||
{ "retries", 1, nullptr, IConfig::RetriesKey },
|
||||
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
|
||||
{ "safe", 0, nullptr, IConfig::SafeKey },
|
||||
{ "syslog", 0, nullptr, IConfig::SyslogKey },
|
||||
{ "threads", 1, nullptr, IConfig::ThreadsKey },
|
||||
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
|
||||
{ "asm", 1, nullptr, IConfig::AssemblyKey },
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_CONFIG_PLATFORM_H */
|
||||
113
src/core/config/usage.h
Normal file
113
src/core/config/usage.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_USAGE_H
|
||||
#define XMRIG_USAGE_H
|
||||
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static char const usage[] = "\
|
||||
Usage: " APP_ID " [OPTIONS]\n\
|
||||
Options:\n\
|
||||
-a, --algo=ALGO specify the algorithm to use\n\
|
||||
cryptonight\n"
|
||||
#ifndef XMRIG_NO_AEON
|
||||
"\
|
||||
cryptonight-lite\n"
|
||||
#endif
|
||||
#ifndef XMRIG_NO_SUMO
|
||||
"\
|
||||
cryptonight-heavy\n"
|
||||
#endif
|
||||
#ifndef XMRIG_NO_CN_PICO
|
||||
"\
|
||||
cryptonight-pico\n"
|
||||
#endif
|
||||
"\
|
||||
-o, --url=URL URL of mining server\n\
|
||||
-O, --userpass=U:P username:password pair for mining server\n\
|
||||
-u, --user=USERNAME username for mining server\n\
|
||||
-p, --pass=PASSWORD password for mining server\n\
|
||||
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
|
||||
-t, --threads=N number of miner threads\n\
|
||||
-v, --av=N algorithm variation, 0 auto select\n\
|
||||
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)\n\
|
||||
--nicehash enable nicehash.com support\n"
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
"\
|
||||
--tls enable SSL/TLS support (needs pool support)\n\
|
||||
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning\n"
|
||||
#endif
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
"\
|
||||
--daemon use daemon RPC instead of pool for solo mining\n\
|
||||
--daemon-poll-interval=N daemon poll interval in milliseconds (default: 1000)\n"
|
||||
#endif
|
||||
"\
|
||||
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
|
||||
-R, --retry-pause=N time to pause between retries (default: 5)\n\
|
||||
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
|
||||
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
|
||||
--no-huge-pages disable huge pages support\n\
|
||||
--no-color disable colored output\n\
|
||||
--variant algorithm PoW variant\n\
|
||||
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
||||
--user-agent set custom user-agent string for pool\n\
|
||||
-B, --background run the miner in the background\n\
|
||||
-c, --config=FILE load a JSON-format configuration file\n\
|
||||
-l, --log-file=FILE log all output to a file\n"
|
||||
# ifdef HAVE_SYSLOG_H
|
||||
"\
|
||||
-S, --syslog use system log for output messages\n"
|
||||
# endif
|
||||
"\
|
||||
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default: 100)\n\
|
||||
--safe safe adjust threads and av settings for current CPU\n\
|
||||
--asm=ASM ASM optimizations, possible values: auto, none, intel, ryzen, bulldozer.\n\
|
||||
--print-time=N print hashrate report every N seconds\n"
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
"\
|
||||
--api-worker-id=ID custom worker-id for API\n\
|
||||
--api-id=ID custom instance ID for API\n\
|
||||
--http-enabled enable HTTP API\n\
|
||||
--http-host=HOST bind host for HTTP API (default: 127.0.0.1)\n\
|
||||
--http-port=N bind port for HTTP API\n\
|
||||
--http-access-token=T access token for HTTP API\n\
|
||||
--http-no-restricted enable full remote access to HTTP API (only if access token set)\n"
|
||||
#endif
|
||||
"\
|
||||
--dry-run test configuration and exit\n\
|
||||
-h, --help display this help and exit\n\
|
||||
-V, --version output version information and exit\n\
|
||||
";
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* XMRIG_USAGE_H */
|
||||
Reference in New Issue
Block a user