Removed IConfigCreator/ConfigCreator and changed file structure.
This commit is contained in:
@ -31,13 +31,14 @@ set(HEADERS
|
||||
src/common/crypto/Algorithm.h
|
||||
src/common/crypto/keccak.h
|
||||
src/common/interfaces/IConfig.h
|
||||
src/common/interfaces/IConfigCreator.h
|
||||
src/common/interfaces/ICpuInfo.h
|
||||
src/common/Platform.h
|
||||
src/common/utils/mm_malloc.h
|
||||
src/common/xmrig.h
|
||||
src/core/ConfigLoader_default.h
|
||||
src/core/ConfigLoader_platform.h
|
||||
src/core/config/Config.h
|
||||
src/core/config/ConfigLoader_default.h
|
||||
src/core/config/ConfigLoader_platform.h
|
||||
src/core/config/usage.h
|
||||
src/core/Controller.h
|
||||
src/interfaces/IJobResultListener.h
|
||||
src/interfaces/IThread.h
|
||||
@ -89,7 +90,7 @@ set(SOURCES
|
||||
src/common/crypto/Algorithm.cpp
|
||||
src/common/crypto/keccak.cpp
|
||||
src/common/Platform.cpp
|
||||
src/core/Config.cpp
|
||||
src/core/config/Config.cpp
|
||||
src/core/Controller.cpp
|
||||
src/Mem.cpp
|
||||
src/net/Network.cpp
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "base/kernel/Signals.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "common/Platform.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "crypto/CryptoNight.h"
|
||||
#include "Mem.h"
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "App.h"
|
||||
#include "core/Controller.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
|
||||
|
||||
void xmrig::App::background()
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "crypto/Asm.h"
|
||||
#include "Mem.h"
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "api/requests/HttpApiRequest.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "common/crypto/keccak.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "version.h"
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "base/net/http/HttpRequest.h"
|
||||
#include "base/net/http/HttpServer.h"
|
||||
#include "base/net/tools/TcpServer.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "base/kernel/Entry.h"
|
||||
#include "base/kernel/Process.h"
|
||||
#include "core/usage.h"
|
||||
#include "core/config/usage.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
@ -36,20 +36,19 @@
|
||||
#include "common/config/ConfigWatcher.h"
|
||||
#include "common/interfaces/IConfig.h"
|
||||
#include "common/Platform.h"
|
||||
#include "core/ConfigCreator.h"
|
||||
#include "core/ConfigLoader_platform.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/config/ConfigLoader_platform.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/error/en.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_EMBEDDED_CONFIG
|
||||
# include "core/ConfigLoader_default.h"
|
||||
# include "core/config/ConfigLoader_default.h"
|
||||
#endif
|
||||
|
||||
|
||||
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
||||
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
||||
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
|
||||
|
||||
|
||||
@ -106,7 +105,7 @@ bool xmrig::ConfigLoader::loadFromJSON(xmrig::IConfig *config, const rapidjson::
|
||||
|
||||
bool xmrig::ConfigLoader::reload(xmrig::IConfig *oldConfig, const char *json)
|
||||
{
|
||||
xmrig::IConfig *config = m_creator->create();
|
||||
IConfig *config = Config::create();
|
||||
if (!loadFromJSON(config, json)) {
|
||||
delete config;
|
||||
|
||||
@ -135,17 +134,16 @@ bool xmrig::ConfigLoader::watch(IConfig *config)
|
||||
|
||||
assert(m_watcher == nullptr);
|
||||
|
||||
m_watcher = new xmrig::ConfigWatcher(config->fileName(), m_creator, m_listener);
|
||||
m_watcher = new xmrig::ConfigWatcher(config->fileName(), m_listener);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *creator, IConfigListener *listener)
|
||||
xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigListener *listener)
|
||||
{
|
||||
m_creator = creator;
|
||||
m_listener = listener;
|
||||
|
||||
xmrig::IConfig *config = m_creator->create();
|
||||
IConfig *config = Config::create();
|
||||
int key;
|
||||
int argc = process->arguments().argc();
|
||||
char **argv = process->arguments().argv();
|
||||
@ -171,7 +169,7 @@ xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *crea
|
||||
if (!config->finalize()) {
|
||||
delete config;
|
||||
|
||||
config = m_creator->create();
|
||||
config = Config::create();
|
||||
loadFromFile(config, process->location(Process::ExeLocation, "config.json"));
|
||||
}
|
||||
|
||||
@ -179,7 +177,7 @@ xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *crea
|
||||
if (!config->finalize()) {
|
||||
delete config;
|
||||
|
||||
config = m_creator->create();
|
||||
config = Config::create();
|
||||
loadFromJSON(config, default_config);
|
||||
}
|
||||
# endif
|
||||
@ -203,10 +201,8 @@ xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *crea
|
||||
void xmrig::ConfigLoader::release()
|
||||
{
|
||||
delete m_watcher;
|
||||
delete m_creator;
|
||||
|
||||
m_watcher = nullptr;
|
||||
m_creator = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,6 @@ namespace xmrig {
|
||||
|
||||
|
||||
class ConfigWatcher;
|
||||
class IConfigCreator;
|
||||
class IConfigListener;
|
||||
class IConfig;
|
||||
class Process;
|
||||
@ -53,7 +52,7 @@ public:
|
||||
static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc);
|
||||
static bool reload(IConfig *oldConfig, const char *json);
|
||||
static bool watch(IConfig *config);
|
||||
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
||||
static IConfig *load(Process *process, IConfigListener *listener);
|
||||
static void release();
|
||||
|
||||
private:
|
||||
@ -62,7 +61,6 @@ private:
|
||||
static void parseJSON(IConfig *config, const struct option *option, const rapidjson::Value &object);
|
||||
|
||||
static ConfigWatcher *m_watcher;
|
||||
static IConfigCreator *m_creator;
|
||||
static IConfigListener *m_listener;
|
||||
};
|
||||
|
||||
|
@ -28,11 +28,10 @@
|
||||
#include "base/kernel/interfaces/IConfigListener.h"
|
||||
#include "common/config/ConfigLoader.h"
|
||||
#include "common/config/ConfigWatcher.h"
|
||||
#include "core/ConfigCreator.h"
|
||||
#include "core/config/Config.h"
|
||||
|
||||
|
||||
xmrig::ConfigWatcher::ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener) :
|
||||
m_creator(creator),
|
||||
xmrig::ConfigWatcher::ConfigWatcher(const String &path, IConfigListener *listener) :
|
||||
m_listener(listener)
|
||||
{
|
||||
m_watcher = new Watcher(path, this);
|
||||
@ -50,7 +49,7 @@ void xmrig::ConfigWatcher::onFileChanged(const String &fileName)
|
||||
{
|
||||
LOG_WARN("\"%s\" was changed, reloading configuration", fileName.data());
|
||||
|
||||
IConfig *config = m_creator->create();
|
||||
IConfig *config = Config::create();
|
||||
ConfigLoader::loadFromFile(config, fileName);
|
||||
|
||||
if (!config->finalize()) {
|
||||
|
@ -37,7 +37,6 @@ struct option;
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IConfigCreator;
|
||||
class IConfigListener;
|
||||
class Watcher;
|
||||
|
||||
@ -45,14 +44,13 @@ class Watcher;
|
||||
class ConfigWatcher : public IWatcherListener
|
||||
{
|
||||
public:
|
||||
ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener);
|
||||
ConfigWatcher(const String &path, IConfigListener *listener);
|
||||
~ConfigWatcher() override;
|
||||
|
||||
protected:
|
||||
void onFileChanged(const String &fileName) override;
|
||||
|
||||
private:
|
||||
IConfigCreator *m_creator;
|
||||
IConfigListener *m_listener;
|
||||
Watcher *m_watcher;
|
||||
};
|
||||
|
@ -152,6 +152,8 @@ public:
|
||||
virtual void getJSON(rapidjson::Document &doc) const = 0;
|
||||
virtual void parseJSON(const rapidjson::Document &doc) = 0;
|
||||
virtual void setFileName(const char *fileName) = 0;
|
||||
|
||||
static IConfig *create();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,47 +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-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_ICONFIGCREATOR_H
|
||||
#define XMRIG_ICONFIGCREATOR_H
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IConfig;
|
||||
|
||||
|
||||
class IConfigCreator
|
||||
{
|
||||
public:
|
||||
virtual ~IConfigCreator() = default;
|
||||
|
||||
virtual IConfig *create() const = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ICONFIGCREATOR_H
|
@ -1,50 +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 2016-2018 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 __CONFIGCREATOR_H__
|
||||
#define __CONFIGCREATOR_H__
|
||||
|
||||
|
||||
#include "common/interfaces/IConfigCreator.h"
|
||||
#include "core/Config.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IConfig;
|
||||
|
||||
|
||||
class ConfigCreator : public IConfigCreator
|
||||
{
|
||||
public:
|
||||
inline IConfig *create() const override
|
||||
{
|
||||
return new Config();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // __CONFIGCREATOR_H__
|
@ -33,7 +33,7 @@
|
||||
#include "common/config/ConfigLoader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "common/Platform.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "net/Network.h"
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "common/config/ConfigLoader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/ConfigCreator.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "crypto/Asm.h"
|
||||
#include "crypto/CryptoNight_constants.h"
|
||||
#include "rapidjson/document.h"
|
||||
@ -129,7 +128,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
|
||||
xmrig::Config *xmrig::Config::load(Process *process, IConfigListener *listener)
|
||||
{
|
||||
return static_cast<Config*>(ConfigLoader::load(process, new ConfigCreator(), listener));
|
||||
return static_cast<Config*>(ConfigLoader::load(process, listener));
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,9 @@ public:
|
||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade) && isAutoSave(); }
|
||||
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
|
||||
inline int priority() const { return m_priority; }
|
||||
inline int threadsCount() const { return m_threads.list.size(); }
|
||||
inline int threadsCount() const { return static_cast<int>(m_threads.list.size()); }
|
||||
inline int64_t affinity() const { return m_threads.mask; }
|
||||
inline static IConfig *create() { return new Config(); }
|
||||
inline ThreadsMode threadsMode() const { return m_threads.mode; }
|
||||
|
||||
static Config *load(Process *process, IConfigListener *listener);
|
@ -37,7 +37,7 @@
|
||||
#include "base/net/stratum/SubmitResult.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Timer.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "net/Network.h"
|
||||
#include "net/strategies/DonateStrategy.h"
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "common/crypto/keccak.h"
|
||||
#include "common/Platform.h"
|
||||
#include "common/xmrig.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "net/Network.h"
|
||||
#include "net/strategies/DonateStrategy.h"
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "workers/Hashrate.h"
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "api/Api.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "crypto/CryptoNight_constants.h"
|
||||
#include "interfaces/IJobResultListener.h"
|
||||
|
Reference in New Issue
Block a user