mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
Added ConfigPrivate class.
This commit is contained in:
parent
bd07f1d455
commit
fe9d2a0e1d
4 changed files with 84 additions and 39 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "backend/common/interfaces/IWorker.h"
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/opencl/OclBackend.h"
|
||||
#include "backend/opencl/OclConfig.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
|
|
|
@ -55,6 +55,11 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/rx/RxConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,16 @@
|
|||
#include "rapidjson/prettywriter.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/rx/RxConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
# include "backend/opencl/OclConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kCPU = "cpu";
|
||||
|
@ -51,14 +61,58 @@ static const char *kRandomX = "randomx";
|
|||
static const char *kOcl = "opencl";
|
||||
#endif
|
||||
|
||||
|
||||
class ConfigPrivate
|
||||
{
|
||||
public:
|
||||
CpuConfig cpu;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
RxConfig rx;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
OclConfig cl;
|
||||
# endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
xmrig::Config::Config() : BaseConfig()
|
||||
xmrig::Config::Config() : BaseConfig(),
|
||||
d_ptr(new ConfigPrivate())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::Config::~Config()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
|
||||
const xmrig::CpuConfig &xmrig::Config::cpu() const
|
||||
{
|
||||
return d_ptr->cpu;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
const xmrig::OclConfig &xmrig::Config::cl() const
|
||||
{
|
||||
return d_ptr->cl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
const xmrig::RxConfig &xmrig::Config::rx() const
|
||||
{
|
||||
return d_ptr->rx;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool xmrig::Config::isShouldSave() const
|
||||
{
|
||||
if (!isAutoSave()) {
|
||||
|
@ -70,12 +124,12 @@ bool xmrig::Config::isShouldSave() const
|
|||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
if (m_cl.isShouldSave()) {
|
||||
if (cl().isShouldSave()) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
||||
return (m_shouldSave || m_upgrade || m_cpu.isShouldSave());
|
||||
return (m_upgrade || cpu().isShouldSave());
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,16 +139,16 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
|||
return false;
|
||||
}
|
||||
|
||||
m_cpu.read(reader.getValue(kCPU), version());
|
||||
d_ptr->cpu.read(reader.getValue(kCPU), version());
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (!m_rx.read(reader.getValue(kRandomX))) {
|
||||
if (!d_ptr->rx.read(reader.getValue(kRandomX))) {
|
||||
m_upgrade = true;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
m_cl.read(reader.getValue(kOcl));
|
||||
d_ptr->cl.read(reader.getValue(kOcl));
|
||||
# endif
|
||||
|
||||
return true;
|
||||
|
@ -121,13 +175,13 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
doc.AddMember("colors", Log::colors, allocator);
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
doc.AddMember(StringRef(kRandomX), m_rx.toJSON(doc), allocator);
|
||||
doc.AddMember(StringRef(kRandomX), rx().toJSON(doc), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember(StringRef(kCPU), m_cpu.toJSON(doc), allocator);
|
||||
doc.AddMember(StringRef(kCPU), cpu().toJSON(doc), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
doc.AddMember(StringRef(kOcl), m_cl.toJSON(doc), allocator);
|
||||
doc.AddMember(StringRef(kOcl), cl().toJSON(doc), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||
|
|
|
@ -34,52 +34,37 @@
|
|||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "crypto/rx/RxConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
# include "backend/opencl/OclConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class ConfigPrivate;
|
||||
class IThread;
|
||||
class RxConfig;
|
||||
class OclConfig;
|
||||
|
||||
|
||||
class Config : public BaseConfig
|
||||
{
|
||||
public:
|
||||
Config();
|
||||
~Config() override;
|
||||
|
||||
const CpuConfig &cpu() const;
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
const OclConfig &cl() const;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
const RxConfig &rx() const;
|
||||
# endif
|
||||
|
||||
bool isShouldSave() const;
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
inline const RxConfig &rx() const { return m_rx; }
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
inline const OclConfig &cl() const { return m_cl; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
bool m_shouldSave = false;
|
||||
CpuConfig m_cpu;
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
RxConfig m_rx;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
OclConfig m_cl;
|
||||
# endif
|
||||
ConfigPrivate *d_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue