Options class replaced to xmrig::Config.
This commit is contained in:
parent
aad19f1a35
commit
aac7b0404a
25 changed files with 240 additions and 1104 deletions
|
@ -40,7 +40,6 @@ xmrig::Config::Config() : xmrig::CommonConfig(),
|
|||
m_dryRun(false),
|
||||
m_hugePages(true),
|
||||
m_safe(false),
|
||||
m_algo(0),
|
||||
m_algoVariant(0),
|
||||
m_maxCpuUsage(75),
|
||||
m_printTime(60),
|
||||
|
@ -151,10 +150,10 @@ bool xmrig::Config::adjust()
|
|||
}
|
||||
|
||||
if (!m_threads) {
|
||||
m_threads = Cpu::optimalThreadsCount(m_algo, m_doubleHash, m_maxCpuUsage);
|
||||
m_threads = Cpu::optimalThreadsCount(m_algorithm, m_doubleHash, m_maxCpuUsage);
|
||||
}
|
||||
else if (m_safe) {
|
||||
const int count = Cpu::optimalThreadsCount(m_algo, m_doubleHash, m_maxCpuUsage);
|
||||
const int count = Cpu::optimalThreadsCount(m_algorithm, m_doubleHash, m_maxCpuUsage);
|
||||
if (m_threads > count) {
|
||||
m_threads = count;
|
||||
}
|
||||
|
@ -296,7 +295,7 @@ bool xmrig::Config::parseInt(int key, int arg)
|
|||
int xmrig::Config::getAlgoVariant() const
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algo == xmrig::ALGO_CRYPTONIGHT_LITE) {
|
||||
if (m_algorithm == xmrig::ALGO_CRYPTONIGHT_LITE) {
|
||||
return getAlgoVariantLite();
|
||||
}
|
||||
# endif
|
||||
|
|
|
@ -79,7 +79,6 @@ public:
|
|||
inline bool isDoubleHash() const { return m_doubleHash; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
inline bool isHugePages() const { return m_hugePages; }
|
||||
inline int algo() const { return m_algo; }
|
||||
inline int algoVariant() const { return m_algoVariant; }
|
||||
inline int printTime() const { return m_printTime; }
|
||||
inline int priority() const { return m_priority; }
|
||||
|
@ -107,7 +106,6 @@ private:
|
|||
bool m_dryRun;
|
||||
bool m_hugePages;
|
||||
bool m_safe;
|
||||
int m_algo;
|
||||
int m_algoVariant;
|
||||
int m_maxCpuUsage;
|
||||
int m_printTime;
|
||||
|
|
|
@ -22,15 +22,19 @@
|
|||
*/
|
||||
|
||||
|
||||
//#include "core/Config.h"
|
||||
//#include "core/ConfigLoader.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "core/Config.h"
|
||||
#include "core/ConfigLoader.h"
|
||||
#include "core/Controller.h"
|
||||
#include "Cpu.h"
|
||||
#include "interfaces/IControllerListener.h"
|
||||
#include "log/ConsoleLog.h"
|
||||
#include "log/FileLog.h"
|
||||
#include "log/Log.h"
|
||||
#include "net/Network.h"
|
||||
#include "Platform.h"
|
||||
//#include "proxy/Proxy.h"
|
||||
#include "interfaces/IControllerListener.h"
|
||||
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
|
@ -42,18 +46,21 @@ class xmrig::ControllerPrivate
|
|||
{
|
||||
public:
|
||||
inline ControllerPrivate() :
|
||||
network(nullptr),
|
||||
config(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
inline ~ControllerPrivate()
|
||||
{
|
||||
// delete config;
|
||||
delete network;
|
||||
delete config;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Config *config;
|
||||
Network *network;
|
||||
std::vector<xmrig::IControllerListener *> listeners;
|
||||
xmrig::Config *config;
|
||||
};
|
||||
|
||||
|
||||
|
@ -65,7 +72,8 @@ xmrig::Controller::Controller()
|
|||
|
||||
xmrig::Controller::~Controller()
|
||||
{
|
||||
// ConfigLoader::release();
|
||||
ConfigLoader::release();
|
||||
Platform::release();
|
||||
|
||||
delete d_ptr;
|
||||
}
|
||||
|
@ -73,39 +81,52 @@ xmrig::Controller::~Controller()
|
|||
|
||||
xmrig::Config *xmrig::Controller::config() const
|
||||
{
|
||||
assert(d_ptr->config != nullptr);
|
||||
|
||||
return d_ptr->config;
|
||||
}
|
||||
|
||||
|
||||
int xmrig::Controller::init(int argc, char **argv)
|
||||
{
|
||||
// d_ptr->config = xmrig::Config::load(argc, argv, this);
|
||||
// if (!d_ptr->config) {
|
||||
// return 1;
|
||||
// }
|
||||
Cpu::init();
|
||||
|
||||
// Log::init();
|
||||
// Platform::init(config()->userAgent());
|
||||
d_ptr->config = xmrig::Config::load(argc, argv, this);
|
||||
if (!d_ptr->config) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if (!config()->background()) {
|
||||
// Log::add(new ConsoleLog(this));
|
||||
// }
|
||||
Log::init();
|
||||
Platform::init(config()->userAgent());
|
||||
Platform::setProcessPriority(d_ptr->config->priority());
|
||||
|
||||
// if (config()->logFile()) {
|
||||
// Log::add(new FileLog(config()->logFile()));
|
||||
// }
|
||||
if (!config()->isBackground()) {
|
||||
Log::add(new ConsoleLog(this));
|
||||
}
|
||||
|
||||
//# ifdef HAVE_SYSLOG_H
|
||||
// if (config()->syslog()) {
|
||||
// Log::add(new SysLog());
|
||||
// }
|
||||
//# endif
|
||||
if (config()->logFile()) {
|
||||
Log::add(new FileLog(config()->logFile()));
|
||||
}
|
||||
|
||||
// d_ptr->proxy = new Proxy(this);
|
||||
# ifdef HAVE_SYSLOG_H
|
||||
if (config()->syslog()) {
|
||||
Log::add(new SysLog());
|
||||
}
|
||||
# endif
|
||||
|
||||
d_ptr->network = new Network(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Network *xmrig::Controller::network() const
|
||||
{
|
||||
assert(d_ptr->network != nullptr);
|
||||
|
||||
return d_ptr->network;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Controller::addListener(IControllerListener *listener)
|
||||
{
|
||||
d_ptr->listeners.push_back(listener);
|
||||
|
@ -114,12 +135,12 @@ void xmrig::Controller::addListener(IControllerListener *listener)
|
|||
|
||||
void xmrig::Controller::onNewConfig(IConfig *config)
|
||||
{
|
||||
// xmrig::Config *previousConfig = d_ptr->config;
|
||||
// d_ptr->config = config;
|
||||
Config *previousConfig = d_ptr->config;
|
||||
d_ptr->config = static_cast<Config*>(config);
|
||||
|
||||
// for (xmrig::IControllerListener *listener : d_ptr->listeners) {
|
||||
// listener->onConfigChanged(config, previousConfig);
|
||||
// }
|
||||
for (xmrig::IControllerListener *listener : d_ptr->listeners) {
|
||||
listener->onConfigChanged(d_ptr->config, previousConfig);
|
||||
}
|
||||
|
||||
// delete previousConfig;
|
||||
delete previousConfig;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "interfaces/IWatcherListener.h"
|
||||
|
||||
|
||||
class Proxy;
|
||||
class Network;
|
||||
class StatsData;
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
Config *config() const;
|
||||
int init(int argc, char **argv);
|
||||
Proxy *proxy() const;
|
||||
Network *network() const;
|
||||
void addListener(IControllerListener *listener);
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue