Added version field to config file.
This commit is contained in:
parent
fe832f510e
commit
ed3a39dc74
6 changed files with 42 additions and 8 deletions
|
@ -128,7 +128,7 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
|
||||||
{
|
{
|
||||||
if (value.IsObject()) {
|
if (value.IsObject()) {
|
||||||
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
||||||
|
@ -148,6 +148,10 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
||||||
if (!m_threads.read(value)) {
|
if (!m_threads.read(value)) {
|
||||||
generate();
|
generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version == 0) {
|
||||||
|
generateArgon2();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (value.IsBool() && value.IsFalse()) {
|
else if (value.IsBool() && value.IsFalse()) {
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
|
@ -187,6 +191,16 @@ void xmrig::CpuConfig::generate()
|
||||||
m_threads.move(kRx, cpu->threads(Algorithm::RX_0));
|
m_threads.move(kRx, cpu->threads(Algorithm::RX_0));
|
||||||
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW));
|
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
generateArgon2();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::CpuConfig::generateArgon2()
|
||||||
|
{
|
||||||
|
# ifdef XMRIG_ALGO_ARGON2
|
||||||
|
m_threads.move(kArgon2, Cpu::info()->threads(Algorithm::AR2_CHUKWA));
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
bool isHwAES() const;
|
bool isHwAES() const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
||||||
void read(const rapidjson::Value &value);
|
void read(const rapidjson::Value &value, uint32_t version);
|
||||||
|
|
||||||
inline bool isEnabled() const { return m_enabled; }
|
inline bool isEnabled() const { return m_enabled; }
|
||||||
inline bool isHugePages() const { return m_hugePages; }
|
inline bool isHugePages() const { return m_hugePages; }
|
||||||
|
@ -61,6 +61,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void generate();
|
void generate();
|
||||||
|
void generateArgon2();
|
||||||
void setAesMode(const rapidjson::Value &aesMode);
|
void setAesMode(const rapidjson::Value &aesMode);
|
||||||
|
|
||||||
inline void setPriority(int priority) { m_priority = (priority >= -1 && priority <= 5) ? priority : -1; }
|
inline void setPriority(int priority) { m_priority = (priority >= -1 && priority <= 5) ? priority : -1; }
|
||||||
|
|
|
@ -134,6 +134,7 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||||
Log::colors = reader.getBool("colors", Log::colors);
|
Log::colors = reader.getBool("colors", Log::colors);
|
||||||
m_logFile = reader.getString("log-file");
|
m_logFile = reader.getString("log-file");
|
||||||
m_userAgent = reader.getString("user-agent");
|
m_userAgent = reader.getString("user-agent");
|
||||||
|
m_version = reader.getUint("version");
|
||||||
|
|
||||||
setPrintTime(reader.getUint("print-time", 60));
|
setPrintTime(reader.getUint("print-time", 60));
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
inline const String &apiId() const { return m_apiId; }
|
inline const String &apiId() const { return m_apiId; }
|
||||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||||
inline uint32_t printTime() const { return m_printTime; }
|
inline uint32_t printTime() const { return m_printTime; }
|
||||||
|
inline uint32_t version() const { return m_version; }
|
||||||
|
|
||||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||||
inline const String &fileName() const override { return m_fileName; }
|
inline const String &fileName() const override { return m_fileName; }
|
||||||
|
@ -80,7 +81,8 @@ protected:
|
||||||
String m_fileName;
|
String m_fileName;
|
||||||
String m_logFile;
|
String m_logFile;
|
||||||
String m_userAgent;
|
String m_userAgent;
|
||||||
uint32_t m_printTime;
|
uint32_t m_printTime = 60;
|
||||||
|
uint32_t m_version = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
static const char *kCPU = "cpu";
|
static const char *kCPU = "cpu";
|
||||||
|
static constexpr const uint32_t kVersion = 1;
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_RANDOMX
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
static const char *kRandomX = "randomx";
|
static const char *kRandomX = "randomx";
|
||||||
|
@ -54,13 +55,27 @@ xmrig::Config::Config() : BaseConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Config::isShouldSave() const
|
||||||
|
{
|
||||||
|
if (!isAutoSave()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version() < kVersion) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (m_shouldSave || m_upgrade || m_cpu.isShouldSave());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||||
{
|
{
|
||||||
if (!BaseConfig::read(reader, fileName)) {
|
if (!BaseConfig::read(reader, fileName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cpu.read(reader.getValue(kCPU));
|
m_cpu.read(reader.getValue(kCPU), version());
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (!m_rx.read(reader.getValue(kRandomX))) {
|
if (!m_rx.read(reader.getValue(kRandomX))) {
|
||||||
|
@ -87,6 +102,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember("api", api, allocator);
|
doc.AddMember("api", api, allocator);
|
||||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||||
|
doc.AddMember("version", kVersion, allocator);
|
||||||
doc.AddMember("background", isBackground(), allocator);
|
doc.AddMember("background", isBackground(), allocator);
|
||||||
doc.AddMember("colors", Log::colors, allocator);
|
doc.AddMember("colors", Log::colors, allocator);
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,10 @@ class Config : public BaseConfig
|
||||||
public:
|
public:
|
||||||
Config();
|
Config();
|
||||||
|
|
||||||
|
bool isShouldSave() const;
|
||||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||||
void getJSON(rapidjson::Document &doc) const override;
|
void getJSON(rapidjson::Document &doc) const override;
|
||||||
|
|
||||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
|
||||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue