mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 00:37:46 +00:00
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()) {
|
||||
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)) {
|
||||
generate();
|
||||
}
|
||||
|
||||
if (version == 0) {
|
||||
generateArgon2();
|
||||
}
|
||||
}
|
||||
else if (value.IsBool() && value.IsFalse()) {
|
||||
m_enabled = false;
|
||||
|
@ -187,6 +191,16 @@ void xmrig::CpuConfig::generate()
|
|||
m_threads.move(kRx, cpu->threads(Algorithm::RX_0));
|
||||
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW));
|
||||
# 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;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) 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 isHugePages() const { return m_hugePages; }
|
||||
|
@ -61,6 +61,7 @@ public:
|
|||
|
||||
private:
|
||||
void generate();
|
||||
void generateArgon2();
|
||||
void setAesMode(const rapidjson::Value &aesMode);
|
||||
|
||||
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);
|
||||
m_logFile = reader.getString("log-file");
|
||||
m_userAgent = reader.getString("user-agent");
|
||||
m_version = reader.getUint("version");
|
||||
|
||||
setPrintTime(reader.getUint("print-time", 60));
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
inline const String &apiId() const { return m_apiId; }
|
||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||
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 const String &fileName() const override { return m_fileName; }
|
||||
|
@ -80,7 +81,8 @@ protected:
|
|||
String m_fileName;
|
||||
String m_logFile;
|
||||
String m_userAgent;
|
||||
uint32_t m_printTime;
|
||||
uint32_t m_printTime = 60;
|
||||
uint32_t m_version = 0;
|
||||
|
||||
private:
|
||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kCPU = "cpu";
|
||||
static const char *kCPU = "cpu";
|
||||
static constexpr const uint32_t kVersion = 1;
|
||||
|
||||
#ifdef XMRIG_ALGO_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)
|
||||
{
|
||||
if (!BaseConfig::read(reader, fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_cpu.read(reader.getValue(kCPU));
|
||||
m_cpu.read(reader.getValue(kCPU), version());
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (!m_rx.read(reader.getValue(kRandomX))) {
|
||||
|
@ -81,12 +96,13 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value api(kObjectType);
|
||||
api.AddMember("id", m_apiId.toJSON(), allocator);
|
||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
||||
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);
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("version", kVersion, allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
|
||||
|
|
|
@ -50,10 +50,10 @@ class Config : public BaseConfig
|
|||
public:
|
||||
Config();
|
||||
|
||||
bool isShouldSave() const;
|
||||
bool read(const IJsonReader &reader, const char *fileName) 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; }
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
|
|
Loading…
Reference in a new issue