xmrig v6.3.1 merge

This commit is contained in:
MoneroOcean 2020-07-31 12:04:00 -07:00
commit 22c39226b0
37 changed files with 308 additions and 251 deletions

View file

@ -143,6 +143,12 @@ static AlgoName const algorithm_names[] = {
} /* namespace xmrig */
xmrig::Algorithm::Algorithm(const rapidjson::Value &value) :
m_id(parse(value.GetString()))
{
}
rapidjson::Value xmrig::Algorithm::toJSON() const
{
using namespace rapidjson;
@ -151,6 +157,12 @@ rapidjson::Value xmrig::Algorithm::toJSON() const
}
rapidjson::Value xmrig::Algorithm::toJSON(rapidjson::Document &) const
{
return toJSON();
}
size_t xmrig::Algorithm::l2() const
{
# ifdef XMRIG_ALGO_RANDOMX

View file

@ -99,6 +99,7 @@ public:
inline Algorithm() = default;
inline Algorithm(const char *algo) : m_id(parse(algo)) {}
inline Algorithm(Id id) : m_id(id) {}
Algorithm(const rapidjson::Value &value);
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO; }
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
@ -115,6 +116,7 @@ public:
inline operator Algorithm::Id() const { return m_id; }
rapidjson::Value toJSON() const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
size_t l2() const;
size_t l3() const;
uint32_t maxIntensity() const;

View file

@ -54,6 +54,8 @@ public:
static inline const char *userAgent() { return m_userAgent; }
static bool isOnBatteryPower();
private:
static char *createUserAgent();

View file

@ -29,6 +29,7 @@
#include <sys/resource.h>
#include <uv.h>
#include <thread>
#include <fstream>
#include "base/kernel/Platform.h"
@ -107,3 +108,18 @@ void xmrig::Platform::setThreadPriority(int priority)
setpriority(PRIO_PROCESS, 0, prio);
}
bool xmrig::Platform::isOnBatteryPower()
{
for (int i = 0; i <= 1; ++i) {
char buf[64];
snprintf(buf, 64, "/sys/class/power_supply/BAT%d/status", i);
std::ifstream f(buf);
if (f.is_open()) {
std::string status;
f >> status;
return (status == "Discharging");
}
}
return false;
}

View file

@ -38,6 +38,7 @@
#include <unistd.h>
#include <uv.h>
#include <thread>
#include <fstream>
#include "base/kernel/Platform.h"
@ -146,3 +147,19 @@ void xmrig::Platform::setThreadPriority(int priority)
}
# endif
}
bool xmrig::Platform::isOnBatteryPower()
{
for (int i = 0; i <= 1; ++i) {
char buf[64];
snprintf(buf, 64, "/sys/class/power_supply/BAT%d/status", i);
std::ifstream f(buf);
if (f.is_open()) {
std::string status;
f >> status;
return (status == "Discharging");
}
}
return false;
}

View file

@ -157,3 +157,12 @@ void xmrig::Platform::setThreadPriority(int priority)
SetThreadPriority(GetCurrentThread(), prio);
}
bool xmrig::Platform::isOnBatteryPower()
{
SYSTEM_POWER_STATUS st;
if (GetSystemPowerStatus(&st)) {
return (st.ACLineStatus == 0);
}
return false;
}

View file

@ -67,6 +67,7 @@ const char *BaseConfig::kColors = "colors";
const char *BaseConfig::kDryRun = "dry-run";
const char *BaseConfig::kHttp = "http";
const char *BaseConfig::kLogFile = "log-file";
const char *BaseConfig::kPauseOnBattery = "pause-on-battery";
const char *BaseConfig::kPrintTime = "print-time";
#ifdef XMRIG_FEATURE_BENCHMARK
const char *BaseConfig::kRebenchAlgo = "rebench-algo";
@ -97,18 +98,19 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
return false;
}
m_autoSave = reader.getBool(kAutosave, m_autoSave);
m_background = reader.getBool(kBackground, m_background);
m_dryRun = reader.getBool(kDryRun, m_dryRun);
m_autoSave = reader.getBool(kAutosave, m_autoSave);
m_background = reader.getBool(kBackground, m_background);
m_dryRun = reader.getBool(kDryRun, m_dryRun);
# ifdef XMRIG_FEATURE_BENCHMARK
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
# endif
m_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
m_title = reader.getValue(kTitle);
m_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
m_title = reader.getValue(kTitle);
# ifdef XMRIG_FEATURE_TLS
m_tls = reader.getValue(kTls);

View file

@ -61,6 +61,7 @@ public:
static const char *kDryRun;
static const char *kHttp;
static const char *kLogFile;
static const char *kPauseOnBattery;
static const char *kPrintTime;
# ifdef XMRIG_FEATURE_BENCHMARK
static const char *kRebenchAlgo;
@ -83,6 +84,7 @@ public:
inline bool isAutoSave() const { return m_autoSave; }
inline bool isBackground() const { return m_background; }
inline bool isDryRun() const { return m_dryRun; }
inline bool isPauseOnBattery() const { return m_pauseOnBattery; }
inline bool isSyslog() const { return m_syslog; }
inline const char *logFile() const { return m_logFile.data(); }
inline const char *userAgent() const { return m_userAgent.data(); }
@ -112,12 +114,13 @@ public:
void printVersions();
protected:
bool m_autoSave = true;
bool m_background = false;
bool m_dryRun = false;
bool m_syslog = false;
bool m_upgrade = false;
bool m_watch = true;
bool m_autoSave = true;
bool m_background = false;
bool m_dryRun = false;
bool m_pauseOnBattery = false;
bool m_syslog = false;
bool m_upgrade = false;
bool m_watch = true;
Http m_http;
Pools m_pools;
String m_apiId;

View file

@ -259,6 +259,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
# ifdef XMRIG_FEATURE_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
# endif
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return transformBoolean(doc, key, true);
case IConfig::ColorKey: /* --no-color */
@ -322,6 +323,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
return set(doc, BaseConfig::kRebenchAlgo, enable);
# endif
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
return set(doc, BaseConfig::kPauseOnBattery, enable);
default:
break;
}

View file

@ -76,6 +76,7 @@ public:
DataDirKey = 1035,
TitleKey = 1037,
NoTitleKey = 1038,
PauseOnBatteryKey = 1041,
// xmrig common
CPUPriorityKey = 1021,
@ -106,6 +107,8 @@ public:
YieldKey = 1030,
AstroBWTMaxSizeKey = 1034,
AstroBWTAVX2Key = 1036,
Argon2ImplKey = 1039,
RandomXCacheQoSKey = 1040,
// xmrig amd
OclPlatformKey = 1400,