Add "autosave" config option.
This commit is contained in:
parent
a63677e255
commit
143da8380e
@ -67,6 +67,7 @@ xmrig::CommonConfig::CommonConfig() :
|
||||
m_adjusted(false),
|
||||
m_apiIPv6(false),
|
||||
m_apiRestricted(true),
|
||||
m_autoSave(true),
|
||||
m_background(false),
|
||||
m_colors(true),
|
||||
m_dryRun(false),
|
||||
@ -217,7 +218,7 @@ bool xmrig::CommonConfig::save()
|
||||
rapidjson::PrettyWriter<rapidjson::FileWriteStream> writer(os);
|
||||
doc.Accept(writer);
|
||||
|
||||
fclose(fp);
|
||||
fflush(fp);
|
||||
|
||||
uv_fs_close(uv_default_loop(), &req, fd, nullptr);
|
||||
uv_fs_req_cleanup(&req);
|
||||
@ -308,10 +309,14 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
|
||||
m_apiRestricted = enable;
|
||||
break;
|
||||
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
case DryRunKey: /* --dry-run */
|
||||
m_dryRun = enable;
|
||||
break;
|
||||
|
||||
case AutoSaveKey:
|
||||
m_autoSave = enable;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
|
||||
inline bool isApiIPv6() const { return m_apiIPv6; }
|
||||
inline bool isApiRestricted() const { return m_apiRestricted; }
|
||||
inline bool isAutoSave() const { return m_autoSave; }
|
||||
inline bool isBackground() const { return m_background; }
|
||||
inline bool isColors() const { return m_colors; }
|
||||
inline bool isDryRun() const { return m_dryRun; }
|
||||
@ -88,6 +89,7 @@ protected:
|
||||
bool m_adjusted;
|
||||
bool m_apiIPv6;
|
||||
bool m_apiRestricted;
|
||||
bool m_autoSave;
|
||||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_dryRun;
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
WatchKey = 1105,
|
||||
TlsKey = 1013,
|
||||
FingerprintKey = 1014,
|
||||
AutoSaveKey = 1016,
|
||||
|
||||
// xmrig common
|
||||
CPUPriorityKey = 1021,
|
||||
|
@ -3,10 +3,13 @@
|
||||
"api": {
|
||||
"port": 0,
|
||||
"access-token": null,
|
||||
"id": null,
|
||||
"worker-id": null,
|
||||
"ipv6": false,
|
||||
"restricted": true
|
||||
"restricted": false
|
||||
},
|
||||
"asm": true,
|
||||
"autosave": true,
|
||||
"av": 0,
|
||||
"background": false,
|
||||
"colors": true,
|
||||
@ -19,13 +22,15 @@
|
||||
"max-cpu-usage": 75,
|
||||
"pools": [
|
||||
{
|
||||
"url": "proxy.fee.xmrig.com:9999",
|
||||
"user": "YOUR_WALLET",
|
||||
"url": "donate.v2.xmrig.com:3333",
|
||||
"user": "YOUR_WALLET_ADDRESS",
|
||||
"pass": "x",
|
||||
"rig-id": null,
|
||||
"nicehash": false,
|
||||
"keepalive": false,
|
||||
"variant": 1
|
||||
"variant": 1,
|
||||
"tls": false,
|
||||
"tls-fingerprint": null
|
||||
}
|
||||
],
|
||||
"print-time": 60,
|
||||
|
@ -47,6 +47,7 @@ xmrig::Config::Config() : xmrig::CommonConfig(),
|
||||
m_assembly(ASM_AUTO),
|
||||
m_hugePages(true),
|
||||
m_safe(false),
|
||||
m_shouldSave(false),
|
||||
m_maxCpuUsage(75),
|
||||
m_priority(-1)
|
||||
{
|
||||
@ -69,10 +70,6 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
|
||||
doc.AddMember("algo", StringRef(algorithm().name()), allocator);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
# endif
|
||||
|
||||
Value api(kObjectType);
|
||||
api.AddMember("port", apiPort(), allocator);
|
||||
api.AddMember("access-token", apiToken() ? Value(StringRef(apiToken())).Move() : Value(kNullType).Move(), allocator);
|
||||
@ -82,6 +79,11 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
api.AddMember("restricted", isApiRestricted(), allocator);
|
||||
doc.AddMember("api", api, allocator);
|
||||
|
||||
# ifndef XMRIG_NO_ASM
|
||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("av", algoVariant(), allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", isColors(), allocator);
|
||||
@ -113,7 +115,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
doc.AddMember("retry-pause", retryPause(), allocator);
|
||||
doc.AddMember("safe", m_safe, allocator);
|
||||
|
||||
if (threadsMode() == Advanced) {
|
||||
if (threadsMode() != Simple) {
|
||||
Value threads(kArrayType);
|
||||
|
||||
for (const IThread *thread : m_threads.list) {
|
||||
@ -123,7 +125,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
doc.AddMember("threads", threads, allocator);
|
||||
}
|
||||
else {
|
||||
doc.AddMember("threads", threadsMode() == Automatic ? Value(kNullType) : Value(threadsCount()), allocator);
|
||||
doc.AddMember("threads", threadsCount(), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("user-agent", userAgent() ? Value(StringRef(userAgent())).Move() : Value(kNullType).Move(), allocator);
|
||||
@ -163,7 +165,7 @@ bool xmrig::Config::finalize()
|
||||
return true;
|
||||
}
|
||||
|
||||
const AlgoVariant av = getAlgoVariant();
|
||||
const AlgoVariant av = getAlgoVariant();
|
||||
m_threads.mode = m_threads.count ? Simple : Automatic;
|
||||
|
||||
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo()) / 1024;
|
||||
@ -182,6 +184,7 @@ bool xmrig::Config::finalize()
|
||||
m_threads.list.push_back(CpuThread::createFromAV(i, m_algorithm.algo(), av, m_threads.mask, m_priority, m_assembly));
|
||||
}
|
||||
|
||||
m_shouldSave = m_threads.mode == Automatic;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
inline AlgoVariant algoVariant() const { return m_algoVariant; }
|
||||
inline Assembly assembly() const { return m_assembly; }
|
||||
inline bool isHugePages() const { return m_hugePages; }
|
||||
inline bool isShouldSave() const { return m_shouldSave && isAutoSave(); }
|
||||
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
|
||||
inline int priority() const { return m_priority; }
|
||||
inline int threadsCount() const { return m_threads.list.size(); }
|
||||
@ -119,6 +120,7 @@ private:
|
||||
Assembly m_assembly;
|
||||
bool m_hugePages;
|
||||
bool m_safe;
|
||||
bool m_shouldSave;
|
||||
int m_maxCpuUsage;
|
||||
int m_priority;
|
||||
Threads m_threads;
|
||||
|
@ -161,6 +161,7 @@ static struct option const config_options[] = {
|
||||
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
|
||||
{ "hw-aes", 0, nullptr, xmrig::IConfig::HardwareAESKey },
|
||||
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
|
||||
{ "autosave", 0, nullptr, xmrig::IConfig::AutoSaveKey },
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
|
@ -200,6 +200,10 @@ void Workers::start(xmrig::Controller *controller)
|
||||
m_workers.push_back(handle);
|
||||
handle->start(Workers::onReady);
|
||||
}
|
||||
|
||||
if (controller->config()->isShouldSave()) {
|
||||
controller->config()->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user