mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-18 16:55:55 +00:00
Update IConfig.
This commit is contained in:
parent
61c263af6e
commit
9ad1c02430
4 changed files with 46 additions and 24 deletions
|
@ -220,7 +220,7 @@ void xmrig::Base::start()
|
|||
}
|
||||
|
||||
if (config()->isWatch()) {
|
||||
d_ptr->watcher = new Watcher(config()->fileName(), this);
|
||||
d_ptr->watcher = new Watcher(config()->path(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ bool xmrig::Base::reload(const rapidjson::Value &json)
|
|||
}
|
||||
|
||||
auto config = new Config();
|
||||
if (!config->read(reader, d_ptr->config->fileName())) {
|
||||
if (!config->read(reader, d_ptr->config->path())) {
|
||||
delete config;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -80,9 +80,9 @@ const char *BaseConfig::kTls = "tls";
|
|||
} // namespace xmrig
|
||||
|
||||
|
||||
bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||
bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *path)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
m_path = path;
|
||||
|
||||
if (reader.isEmpty()) {
|
||||
return false;
|
||||
|
@ -122,15 +122,22 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
|
||||
bool xmrig::BaseConfig::save()
|
||||
{
|
||||
if (m_fileName.isNull()) {
|
||||
rapidjson::Document doc;
|
||||
|
||||
return save(doc);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::BaseConfig::save(rapidjson::Document &doc)
|
||||
{
|
||||
if (m_path.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rapidjson::Document doc;
|
||||
getJSON(doc);
|
||||
|
||||
if (Json::save(m_fileName, doc)) {
|
||||
LOG_NOTICE("%s " WHITE_BOLD("configuration saved to: \"%s\""), Tags::config(), m_fileName.data());
|
||||
if (Json::save(m_path, doc)) {
|
||||
LOG_NOTICE("%s " WHITE_BOLD("configuration saved to: \"%s\""), Tags::config(), m_path.data());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,12 +86,14 @@ public:
|
|||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
# endif
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const String &fileName() const override { return m_fileName; }
|
||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||
inline bool isWatch() const override { return m_watch && !m_path.isNull(); }
|
||||
inline const String &path() const override { return m_path; }
|
||||
inline uint32_t id() const override { return 0; }
|
||||
inline void setPath(const char *path) override { m_path = path; }
|
||||
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
bool save() override;
|
||||
bool read(const IJsonReader &reader, const char *path) override;
|
||||
bool save();
|
||||
bool save(rapidjson::Document &doc) override;
|
||||
|
||||
static void printVersions();
|
||||
|
||||
|
@ -106,8 +108,8 @@ protected:
|
|||
Pools m_pools;
|
||||
String m_apiId;
|
||||
String m_apiWorkerId;
|
||||
String m_fileName;
|
||||
String m_logFile;
|
||||
String m_path;
|
||||
String m_userAgent;
|
||||
Title m_title;
|
||||
uint32_t m_printTime = 60;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2022 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2022 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,6 +21,7 @@
|
|||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -33,6 +34,9 @@ class String;
|
|||
class IConfig
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IConfig)
|
||||
|
||||
# ifndef XMRIG_FEATURE_EVENTS
|
||||
enum Keys {
|
||||
// common
|
||||
AlgorithmKey = 'a',
|
||||
|
@ -164,19 +168,28 @@ public:
|
|||
NvmlKey = 1209,
|
||||
HealthPrintTimeKey = 1210,
|
||||
};
|
||||
# endif
|
||||
|
||||
virtual ~IConfig() = default;
|
||||
IConfig() = default;
|
||||
virtual ~IConfig() = default;
|
||||
|
||||
virtual bool isWatch() const = 0;
|
||||
virtual bool read(const IJsonReader &reader, const char *fileName) = 0;
|
||||
virtual bool save() = 0;
|
||||
virtual const String &fileName() const = 0;
|
||||
virtual void getJSON(rapidjson::Document &doc) const = 0;
|
||||
virtual void setFileName(const char *fileName) = 0;
|
||||
virtual bool save(rapidjson::Document &doc) = 0;
|
||||
virtual const String &path() const = 0;
|
||||
virtual uint32_t id() const = 0;
|
||||
|
||||
# ifdef XMRIG_FEATURE_EVENTS
|
||||
virtual bool isValid() const = 0;
|
||||
virtual const String &name() const = 0;
|
||||
# else
|
||||
virtual bool isWatch() const = 0;
|
||||
virtual bool read(const IJsonReader &reader, const char *path) = 0;
|
||||
virtual void getJSON(rapidjson::Document &doc) const = 0;
|
||||
virtual void setPath(const char *path) = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif // XMRIG_ICONFIG_H
|
||||
|
|
Loading…
Reference in a new issue