Added config only boolean option "hw-aes".

This commit is contained in:
XMRig 2018-04-15 19:25:09 +07:00
parent f0158ae505
commit f8bf48a522
3 changed files with 30 additions and 30 deletions

View file

@ -67,53 +67,49 @@ bool xmrig::Config::reload(const char *json)
void xmrig::Config::getJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;
doc.SetObject();
auto &allocator = doc.GetAllocator();
doc.AddMember("algo", rapidjson::StringRef(algoName()), allocator);
doc.AddMember("algo", StringRef(algoName()), allocator);
rapidjson::Value api(rapidjson::kObjectType);
Value api(kObjectType);
api.AddMember("port", apiPort(), allocator);
api.AddMember("access-token", apiToken() ? rapidjson::Value(rapidjson::StringRef(apiToken())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
api.AddMember("worker-id", apiWorkerId() ? rapidjson::Value(rapidjson::StringRef(apiWorkerId())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
api.AddMember("access-token", apiToken() ? Value(StringRef(apiToken())).Move() : Value(kNullType).Move(), allocator);
api.AddMember("worker-id", apiWorkerId() ? Value(StringRef(apiWorkerId())).Move() : Value(kNullType).Move(), allocator);
api.AddMember("ipv6", isApiIPv6(), allocator);
api.AddMember("restricted", isApiRestricted(), allocator);
doc.AddMember("api", api, allocator);
doc.AddMember("av", algoVariant(), allocator);
doc.AddMember("background", isBackground(), allocator);
doc.AddMember("colors", isColors(), allocator);
doc.AddMember("colors", isColors(), allocator);
if (affinity() != -1L) {
snprintf(affinity_tmp, sizeof(affinity_tmp) - 1, "0x%" PRIX64, affinity());
doc.AddMember("cpu-affinity", rapidjson::StringRef(affinity_tmp), allocator);
doc.AddMember("cpu-affinity", StringRef(affinity_tmp), allocator);
}
else {
doc.AddMember("cpu-affinity", rapidjson::kNullType, allocator);
}
if (priority() != -1) {
doc.AddMember("cpu-priority", priority(), allocator);
}
else {
doc.AddMember("cpu-priority", rapidjson::kNullType, allocator);
doc.AddMember("cpu-affinity", kNullType, allocator);
}
doc.AddMember("cpu-priority", priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
doc.AddMember("donate-level", donateLevel(), allocator);
doc.AddMember("huge-pages", isHugePages(), allocator);
doc.AddMember("log-file", logFile() ? rapidjson::Value(rapidjson::StringRef(logFile())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
doc.AddMember("hw-aes", m_aesMode == AES_AUTO ? Value(kNullType) : Value(m_aesMode == AES_HW), allocator);
doc.AddMember("log-file", logFile() ? Value(StringRef(logFile())).Move() : Value(kNullType).Move(), allocator);
doc.AddMember("max-cpu-usage", m_maxCpuUsage, allocator);
rapidjson::Value pools(rapidjson::kArrayType);
Value pools(kArrayType);
for (const Pool &pool : m_pools) {
rapidjson::Value obj(rapidjson::kObjectType);
Value obj(kObjectType);
obj.AddMember("url", rapidjson::StringRef(pool.url()), allocator);
obj.AddMember("user", rapidjson::StringRef(pool.user()), allocator);
obj.AddMember("pass", rapidjson::StringRef(pool.password()), allocator);
obj.AddMember("url", StringRef(pool.url()), allocator);
obj.AddMember("user", StringRef(pool.user()), allocator);
obj.AddMember("pass", StringRef(pool.password()), allocator);
if (pool.keepAlive() == 0 || pool.keepAlive() == Pool::kKeepAliveTimeout) {
obj.AddMember("keepalive", pool.keepAlive() > 0, allocator);
@ -134,7 +130,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember("retry-pause", retryPause(), allocator);
doc.AddMember("safe", m_safe, allocator);
doc.AddMember("threads", threadsCount(), allocator);
doc.AddMember("user-agent", userAgent() ? rapidjson::Value(rapidjson::StringRef(userAgent())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
doc.AddMember("user-agent", userAgent() ? Value(StringRef(userAgent())).Move() : Value(kNullType).Move(), allocator);
# ifdef HAVE_SYSLOG_H
doc.AddMember("syslog", isSyslog(), allocator);
@ -156,13 +152,11 @@ bool xmrig::Config::adjust()
return false;
}
if (m_aesMode == AES_AUTO) {
m_aesMode = Cpu::hasAES() ? AES_HW : AES_SOFT;
}
if (!m_threads.cpu.empty()) {
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
for (size_t i = 0; i < m_threads.cpu.size(); ++i) {
m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm, m_threads.cpu[i], m_priority, m_aesMode == AES_SOFT));
m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm, m_threads.cpu[i], m_priority, softAES));
}
return true;
@ -198,18 +192,22 @@ bool xmrig::Config::parseBoolean(int key, bool enable)
}
switch (key) {
case xmrig::IConfig::SafeKey: /* --safe */
case IConfig::SafeKey: /* --safe */
m_safe = enable;
break;
case xmrig::IConfig::HugePagesKey: /* --no-huge-pages */
case IConfig::HugePagesKey: /* --no-huge-pages */
m_hugePages = enable;
break;
case xmrig::IConfig::DryRunKey: /* --dry-run */
case IConfig::DryRunKey: /* --dry-run */
m_dryRun = enable;
break;
case IConfig::HardwareAESKey: /* hw-aes config only */
m_aesMode = enable ? AES_HW : AES_SOFT;
break;
default:
break;
}

View file

@ -150,6 +150,7 @@ static struct option const config_options[] = {
{ "syslog", 0, nullptr, xmrig::IConfig::SyslogKey },
{ "threads", 1, nullptr, xmrig::IConfig::ThreadsKey },
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
{ "hw-aes", 0, nullptr, xmrig::IConfig::HardwareAESKey },
{ 0, 0, 0, 0 }
};

View file

@ -74,6 +74,7 @@ public:
MaxCPUUsageKey = 1004,
SafeKey = 1005,
ThreadsKey = 't',
HardwareAESKey = 1011,
// xmrig-proxy
AccessLogFileKey = 'A',