mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-03 17:40:13 +00:00
Added command line option --pause-on-battery and renamed config option.
This commit is contained in:
parent
6484bbb716
commit
32e9b7e34a
10 changed files with 32 additions and 25 deletions
|
@ -61,13 +61,13 @@ const char *BaseConfig::kColors = "colors";
|
||||||
const char *BaseConfig::kDryRun = "dry-run";
|
const char *BaseConfig::kDryRun = "dry-run";
|
||||||
const char *BaseConfig::kHttp = "http";
|
const char *BaseConfig::kHttp = "http";
|
||||||
const char *BaseConfig::kLogFile = "log-file";
|
const char *BaseConfig::kLogFile = "log-file";
|
||||||
|
const char *BaseConfig::kPauseOnBattery = "pause-on-battery";
|
||||||
const char *BaseConfig::kPrintTime = "print-time";
|
const char *BaseConfig::kPrintTime = "print-time";
|
||||||
const char *BaseConfig::kSyslog = "syslog";
|
const char *BaseConfig::kSyslog = "syslog";
|
||||||
const char *BaseConfig::kTitle = "title";
|
const char *BaseConfig::kTitle = "title";
|
||||||
const char *BaseConfig::kUserAgent = "user-agent";
|
const char *BaseConfig::kUserAgent = "user-agent";
|
||||||
const char *BaseConfig::kVerbose = "verbose";
|
const char *BaseConfig::kVerbose = "verbose";
|
||||||
const char *BaseConfig::kWatch = "watch";
|
const char *BaseConfig::kWatch = "watch";
|
||||||
const char *BaseConfig::kMineOnBattery = "mine-on-battery";
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_TLS
|
#ifdef XMRIG_FEATURE_TLS
|
||||||
|
@ -86,16 +86,16 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_autoSave = reader.getBool(kAutosave, m_autoSave);
|
m_autoSave = reader.getBool(kAutosave, m_autoSave);
|
||||||
m_background = reader.getBool(kBackground, m_background);
|
m_background = reader.getBool(kBackground, m_background);
|
||||||
m_dryRun = reader.getBool(kDryRun, m_dryRun);
|
m_dryRun = reader.getBool(kDryRun, m_dryRun);
|
||||||
m_syslog = reader.getBool(kSyslog, m_syslog);
|
m_syslog = reader.getBool(kSyslog, m_syslog);
|
||||||
m_watch = reader.getBool(kWatch, m_watch);
|
m_watch = reader.getBool(kWatch, m_watch);
|
||||||
m_mineOnBattery = reader.getBool(kMineOnBattery, m_mineOnBattery);
|
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
|
||||||
m_logFile = reader.getString(kLogFile);
|
m_logFile = reader.getString(kLogFile);
|
||||||
m_userAgent = reader.getString(kUserAgent);
|
m_userAgent = reader.getString(kUserAgent);
|
||||||
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
|
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);
|
||||||
m_title = reader.getValue(kTitle);
|
m_title = reader.getValue(kTitle);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
m_tls = reader.getValue(kTls);
|
m_tls = reader.getValue(kTls);
|
||||||
|
|
|
@ -55,13 +55,13 @@ public:
|
||||||
static const char *kDryRun;
|
static const char *kDryRun;
|
||||||
static const char *kHttp;
|
static const char *kHttp;
|
||||||
static const char *kLogFile;
|
static const char *kLogFile;
|
||||||
|
static const char *kPauseOnBattery;
|
||||||
static const char *kPrintTime;
|
static const char *kPrintTime;
|
||||||
static const char *kSyslog;
|
static const char *kSyslog;
|
||||||
static const char *kTitle;
|
static const char *kTitle;
|
||||||
static const char *kUserAgent;
|
static const char *kUserAgent;
|
||||||
static const char *kVerbose;
|
static const char *kVerbose;
|
||||||
static const char *kWatch;
|
static const char *kWatch;
|
||||||
static const char* kMineOnBattery;
|
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
static const char *kTls;
|
static const char *kTls;
|
||||||
|
@ -72,6 +72,7 @@ public:
|
||||||
inline bool isAutoSave() const { return m_autoSave; }
|
inline bool isAutoSave() const { return m_autoSave; }
|
||||||
inline bool isBackground() const { return m_background; }
|
inline bool isBackground() const { return m_background; }
|
||||||
inline bool isDryRun() const { return m_dryRun; }
|
inline bool isDryRun() const { return m_dryRun; }
|
||||||
|
inline bool isPauseOnBattery() const { return m_pauseOnBattery; }
|
||||||
inline bool isSyslog() const { return m_syslog; }
|
inline bool isSyslog() const { return m_syslog; }
|
||||||
inline const char *logFile() const { return m_logFile.data(); }
|
inline const char *logFile() const { return m_logFile.data(); }
|
||||||
inline const char *userAgent() const { return m_userAgent.data(); }
|
inline const char *userAgent() const { return m_userAgent.data(); }
|
||||||
|
@ -81,7 +82,6 @@ public:
|
||||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||||
inline const Title &title() const { return m_title; }
|
inline const Title &title() const { return m_title; }
|
||||||
inline uint32_t printTime() const { return m_printTime; }
|
inline uint32_t printTime() const { return m_printTime; }
|
||||||
inline bool mineOnBattery() const { return m_mineOnBattery; }
|
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
inline const TlsConfig &tls() const { return m_tls; }
|
inline const TlsConfig &tls() const { return m_tls; }
|
||||||
|
@ -97,13 +97,13 @@ public:
|
||||||
void printVersions();
|
void printVersions();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_autoSave = true;
|
bool m_autoSave = true;
|
||||||
bool m_background = false;
|
bool m_background = false;
|
||||||
bool m_dryRun = false;
|
bool m_dryRun = false;
|
||||||
bool m_syslog = false;
|
bool m_pauseOnBattery = false;
|
||||||
bool m_upgrade = false;
|
bool m_syslog = false;
|
||||||
bool m_watch = true;
|
bool m_upgrade = false;
|
||||||
bool m_mineOnBattery = true;
|
bool m_watch = true;
|
||||||
Http m_http;
|
Http m_http;
|
||||||
Pools m_pools;
|
Pools m_pools;
|
||||||
String m_apiId;
|
String m_apiId;
|
||||||
|
|
|
@ -247,6 +247,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||||
case IConfig::DaemonKey: /* --daemon */
|
case IConfig::DaemonKey: /* --daemon */
|
||||||
case IConfig::VerboseKey: /* --verbose */
|
case IConfig::VerboseKey: /* --verbose */
|
||||||
|
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
|
||||||
return transformBoolean(doc, key, true);
|
return transformBoolean(doc, key, true);
|
||||||
|
|
||||||
case IConfig::ColorKey: /* --no-color */
|
case IConfig::ColorKey: /* --no-color */
|
||||||
|
@ -305,6 +306,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
||||||
case IConfig::NoTitleKey: /* --no-title */
|
case IConfig::NoTitleKey: /* --no-title */
|
||||||
return set(doc, BaseConfig::kTitle, enable);
|
return set(doc, BaseConfig::kTitle, enable);
|
||||||
|
|
||||||
|
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
|
||||||
|
return set(doc, BaseConfig::kPauseOnBattery, enable);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
DataDirKey = 1035,
|
DataDirKey = 1035,
|
||||||
TitleKey = 1037,
|
TitleKey = 1037,
|
||||||
NoTitleKey = 1038,
|
NoTitleKey = 1038,
|
||||||
|
PauseOnBatteryKey = 1041,
|
||||||
|
|
||||||
// xmrig common
|
// xmrig common
|
||||||
CPUPriorityKey = 1021,
|
CPUPriorityKey = 1021,
|
||||||
|
|
|
@ -92,5 +92,5 @@
|
||||||
"user-agent": null,
|
"user-agent": null,
|
||||||
"verbose": 0,
|
"verbose": 0,
|
||||||
"watch": true,
|
"watch": true,
|
||||||
"mine-on-battery": true
|
"pause-on-battery": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,8 +551,8 @@ void xmrig::Miner::onTimer(const Timer *)
|
||||||
|
|
||||||
d_ptr->ticks++;
|
d_ptr->ticks++;
|
||||||
|
|
||||||
if (!d_ptr->controller->config()->mineOnBattery()) {
|
if (d_ptr->controller->config()->isPauseOnBattery()) {
|
||||||
const bool battery_power = xmrig::Platform::isOnBatteryPower();
|
const bool battery_power = Platform::isOnBatteryPower();
|
||||||
if (battery_power && d_ptr->enabled) {
|
if (battery_power && d_ptr->enabled) {
|
||||||
LOG_INFO("%s " YELLOW_BOLD("on battery power"), Tags::miner());
|
LOG_INFO("%s " YELLOW_BOLD("on battery power"), Tags::miner());
|
||||||
d_ptr->battery_power = true;
|
d_ptr->battery_power = true;
|
||||||
|
|
|
@ -252,5 +252,5 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
||||||
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||||
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||||
doc.AddMember(StringRef(kMineOnBattery), m_mineOnBattery, allocator);
|
doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ R"===(
|
||||||
"syslog": false,
|
"syslog": false,
|
||||||
"user-agent": null,
|
"user-agent": null,
|
||||||
"watch": true,
|
"watch": true,
|
||||||
"mine-on-battery": true
|
"pause-on-battery": false
|
||||||
}
|
}
|
||||||
)===";
|
)===";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -95,6 +95,7 @@ static const option options[] = {
|
||||||
{ "data-dir", 1, nullptr, IConfig::DataDirKey },
|
{ "data-dir", 1, nullptr, IConfig::DataDirKey },
|
||||||
{ "title", 1, nullptr, IConfig::TitleKey },
|
{ "title", 1, nullptr, IConfig::TitleKey },
|
||||||
{ "no-title", 0, nullptr, IConfig::NoTitleKey },
|
{ "no-title", 0, nullptr, IConfig::NoTitleKey },
|
||||||
|
{ "pause-on-battery", 0, nullptr, IConfig::PauseOnBatteryKey },
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
{ "tls", 0, nullptr, IConfig::TlsKey },
|
{ "tls", 0, nullptr, IConfig::TlsKey },
|
||||||
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
|
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
|
||||||
|
|
|
@ -177,6 +177,7 @@ static inline const std::string &usage()
|
||||||
u += " --title set custom console window title\n";
|
u += " --title set custom console window title\n";
|
||||||
u += " --no-title disable setting console window title\n";
|
u += " --no-title disable setting console window title\n";
|
||||||
# endif
|
# endif
|
||||||
|
u += " --pause-on-battery pause mine on battery power\n";
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue