Add "autosave" config option.

This commit is contained in:
XMRig 2018-09-27 19:07:04 +03:00
parent a63677e255
commit 143da8380e
8 changed files with 36 additions and 13 deletions

View file

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

View file

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

View file

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