Sync changes with amd miner and update summary.
This commit is contained in:
parent
34a3454784
commit
009bd1a507
8 changed files with 97 additions and 74 deletions
|
@ -72,6 +72,40 @@ xmrig::CommonConfig::~CommonConfig()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CommonConfig::save()
|
||||
{
|
||||
if (m_fileName.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uv_fs_t req;
|
||||
const int fd = uv_fs_open(uv_default_loop(), &req, m_fileName.data(), O_WRONLY | O_CREAT | O_TRUNC, 0644, nullptr);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
rapidjson::Document doc;
|
||||
getJSON(doc);
|
||||
|
||||
FILE *fp = fdopen(fd, "w");
|
||||
|
||||
char buf[4096];
|
||||
rapidjson::FileWriteStream os(fp, buf, sizeof(buf));
|
||||
rapidjson::PrettyWriter<rapidjson::FileWriteStream> writer(os);
|
||||
doc.Accept(writer);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
uv_fs_close(uv_default_loop(), &req, fd, nullptr);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
LOG_NOTICE("configuration saved to: \"%s\"", m_fileName.data());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CommonConfig::finalize()
|
||||
{
|
||||
if (m_state == ReadyState) {
|
||||
|
@ -254,40 +288,6 @@ bool xmrig::CommonConfig::parseUint64(int key, uint64_t arg)
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CommonConfig::save()
|
||||
{
|
||||
if (m_fileName.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uv_fs_t req;
|
||||
const int fd = uv_fs_open(uv_default_loop(), &req, m_fileName.data(), O_WRONLY | O_CREAT | O_TRUNC, 0644, nullptr);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
rapidjson::Document doc;
|
||||
getJSON(doc);
|
||||
|
||||
FILE *fp = fdopen(fd, "w");
|
||||
|
||||
char buf[4096];
|
||||
rapidjson::FileWriteStream os(fp, buf, sizeof(buf));
|
||||
rapidjson::PrettyWriter<rapidjson::FileWriteStream> writer(os);
|
||||
doc.Accept(writer);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
uv_fs_close(uv_default_loop(), &req, fd, nullptr);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
LOG_NOTICE("configuration saved to: \"%s\"", m_fileName.data());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CommonConfig::setFileName(const char *fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const char *fileName() const override { return m_fileName.data(); }
|
||||
|
||||
bool save() override;
|
||||
|
||||
protected:
|
||||
enum State {
|
||||
NoneState,
|
||||
|
@ -75,7 +77,6 @@ protected:
|
|||
bool parseBoolean(int key, bool enable) override;
|
||||
bool parseString(int key, const char *arg) override;
|
||||
bool parseUint64(int key, uint64_t arg) override;
|
||||
bool save() override;
|
||||
void setFileName(const char *fileName) override;
|
||||
|
||||
Algorithm m_algorithm;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue