Added version field to config file.

This commit is contained in:
XMRig 2019-08-17 04:27:37 +07:00
parent fe832f510e
commit ed3a39dc74
6 changed files with 42 additions and 8 deletions

View file

@ -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);