Added version field to config file.
This commit is contained in:
parent
fe832f510e
commit
ed3a39dc74
6 changed files with 42 additions and 8 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue