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