From 8e3fec5768cc8d584be6460a283ccba1559a6163 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 12 Feb 2021 22:51:26 +0700 Subject: [PATCH 01/10] v6.8.3 --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 43ec81c27..e0fd2f58a 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.8.2" +#define APP_VERSION "6.8.3-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 8 -#define APP_VER_PATCH 2 +#define APP_VER_PATCH 3 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 82830e359a1df896f79ae1ed743e70af357f736a Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 14 Feb 2021 15:32:18 +0100 Subject: [PATCH 02/10] Added `pause-on-active` option Windows only for now. When set to true, pauses mining when user touches mouse or keyboard. --- src/base/kernel/Platform.h | 1 + src/base/kernel/Platform_unix.cpp | 7 +++++++ src/base/kernel/Platform_win.cpp | 13 +++++++++++++ src/base/kernel/config/BaseConfig.cpp | 2 ++ src/base/kernel/config/BaseConfig.h | 3 +++ src/base/kernel/config/BaseTransform.cpp | 4 ++++ src/base/kernel/interfaces/IConfig.h | 1 + src/config.json | 3 ++- src/core/Miner.cpp | 23 +++++++++++++++++++---- src/core/config/Config.cpp | 1 + src/core/config/Config_default.h | 3 ++- src/core/config/Config_platform.h | 1 + src/core/config/usage.h | 1 + 13 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index 293cedc7f..f38804896 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/Platform.h @@ -49,6 +49,7 @@ public: static inline const String &userAgent() { return m_userAgent; } static bool isOnBatteryPower(); + static bool isUserActive(); private: static char *createUserAgent(); diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index bbded9f65..cf7d37ca3 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -158,3 +158,10 @@ bool xmrig::Platform::isOnBatteryPower() } return false; } + + +bool xmrig::Platform::isUserActive() +{ + // TODO + return false; +} diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index a487e17b9..7667691b0 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -161,3 +161,16 @@ bool xmrig::Platform::isOnBatteryPower() } return false; } + + +bool xmrig::Platform::isUserActive() +{ + LASTINPUTINFO info; + info.cbSize = sizeof(LASTINPUTINFO); + + if (!GetLastInputInfo(&info)) { + return false; + } + + return static_cast(GetTickCount() - info.dwTime) < 60 * 1000; +} diff --git a/src/base/kernel/config/BaseConfig.cpp b/src/base/kernel/config/BaseConfig.cpp index 27aa2ce90..c2f4196e3 100644 --- a/src/base/kernel/config/BaseConfig.cpp +++ b/src/base/kernel/config/BaseConfig.cpp @@ -62,6 +62,7 @@ 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::kPauseOnActive = "pause-on-active"; const char *BaseConfig::kPrintTime = "print-time"; const char *BaseConfig::kSyslog = "syslog"; const char *BaseConfig::kTitle = "title"; @@ -92,6 +93,7 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName) m_syslog = reader.getBool(kSyslog, m_syslog); m_watch = reader.getBool(kWatch, m_watch); m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery); + m_pauseOnActive = reader.getBool(kPauseOnActive, m_pauseOnActive); m_logFile = reader.getString(kLogFile); m_userAgent = reader.getString(kUserAgent); m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U); diff --git a/src/base/kernel/config/BaseConfig.h b/src/base/kernel/config/BaseConfig.h index f97a711bb..4f28cadf6 100644 --- a/src/base/kernel/config/BaseConfig.h +++ b/src/base/kernel/config/BaseConfig.h @@ -56,6 +56,7 @@ public: static const char *kHttp; static const char *kLogFile; static const char *kPauseOnBattery; + static const char *kPauseOnActive; static const char *kPrintTime; static const char *kSyslog; static const char *kTitle; @@ -73,6 +74,7 @@ public: inline bool isBackground() const { return m_background; } inline bool isDryRun() const { return m_dryRun; } inline bool isPauseOnBattery() const { return m_pauseOnBattery; } + inline bool isPauseOnActive() const { return m_pauseOnActive; } 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(); } @@ -101,6 +103,7 @@ protected: bool m_background = false; bool m_dryRun = false; bool m_pauseOnBattery = false; + bool m_pauseOnActive = false; bool m_syslog = false; bool m_upgrade = false; bool m_watch = true; diff --git a/src/base/kernel/config/BaseTransform.cpp b/src/base/kernel/config/BaseTransform.cpp index 119fa679c..7df0a7952 100644 --- a/src/base/kernel/config/BaseTransform.cpp +++ b/src/base/kernel/config/BaseTransform.cpp @@ -262,6 +262,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch case IConfig::DaemonKey: /* --daemon */ case IConfig::VerboseKey: /* --verbose */ case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ + case IConfig::PauseOnActiveKey: /* --pause-on-active */ return transformBoolean(doc, key, true); case IConfig::ColorKey: /* --no-color */ @@ -323,6 +324,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ return set(doc, BaseConfig::kPauseOnBattery, enable); + case IConfig::PauseOnActiveKey: /* --pause-on-active */ + return set(doc, BaseConfig::kPauseOnActive, enable); + default: break; } diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index ba022fa3c..d5fdb5c92 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -86,6 +86,7 @@ public: BenchTokenKey = 1048, DmiKey = 1049, HugePageSizeKey = 1050, + PauseOnActiveKey = 1051, // xmrig common CPUPriorityKey = 1021, diff --git a/src/config.json b/src/config.json index 8b5532d5e..7722d19b3 100644 --- a/src/config.json +++ b/src/config.json @@ -96,5 +96,6 @@ "user-agent": null, "verbose": 0, "watch": true, - "pause-on-battery": false + "pause-on-battery": false, + "pause-on-active": false } diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 8d0263e22..6b3a74ba8 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -352,6 +352,7 @@ public: Algorithms algorithms; bool active = false; bool battery_power = false; + bool user_active = false; bool enabled = true; bool reset = true; Controller *controller; @@ -629,18 +630,32 @@ void xmrig::Miner::onTimer(const Timer *) if (d_ptr->controller->config()->isPauseOnBattery()) { const bool battery_power = Platform::isOnBatteryPower(); - if (battery_power && d_ptr->enabled) { + if (battery_power && !d_ptr->battery_power) { LOG_INFO("%s " YELLOW_BOLD("on battery power"), Tags::miner()); d_ptr->battery_power = true; - setEnabled(false); } - else if (!battery_power && !d_ptr->enabled && d_ptr->battery_power) { + else if (!battery_power && d_ptr->battery_power) { LOG_INFO("%s " GREEN_BOLD("on AC power"), Tags::miner()); d_ptr->battery_power = false; - setEnabled(true); } } + if (d_ptr->controller->config()->isPauseOnActive()) { + const bool user_active = Platform::isUserActive(); + if (user_active && !d_ptr->user_active) { + LOG_INFO("%s " YELLOW_BOLD("user active"), Tags::miner()); + d_ptr->user_active = true; + } + else if (!user_active && d_ptr->user_active) { + LOG_INFO("%s " GREEN_BOLD("user inactive"), Tags::miner()); + d_ptr->user_active = false; + } + } + + const bool batteryEnabled = !(d_ptr->controller->config()->isPauseOnBattery() && d_ptr->battery_power); + const bool userActiveEnabled = !(d_ptr->controller->config()->isPauseOnActive() && d_ptr->user_active); + setEnabled(batteryEnabled && userActiveEnabled); + if (stopMiner) { stop(); } diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index f8b7bb858..f2a0c4a93 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -270,4 +270,5 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator); doc.AddMember(StringRef(kWatch), m_watch, allocator); doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator); + doc.AddMember(StringRef(kPauseOnActive), isPauseOnActive(), allocator); } diff --git a/src/core/config/Config_default.h b/src/core/config/Config_default.h index dd7a20832..c16d421ee 100644 --- a/src/core/config/Config_default.h +++ b/src/core/config/Config_default.h @@ -126,7 +126,8 @@ R"===( "user-agent": null, "verbose": 0, "watch": true, - "pause-on-battery": false + "pause-on-battery": false, + "pause-on-active": false } )==="; #endif diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index 28b1e2bda..d1b17345f 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -98,6 +98,7 @@ static const option options[] = { { "title", 1, nullptr, IConfig::TitleKey }, { "no-title", 0, nullptr, IConfig::NoTitleKey }, { "pause-on-battery", 0, nullptr, IConfig::PauseOnBatteryKey }, + { "pause-on-active", 0, nullptr, IConfig::PauseOnActiveKey }, # ifdef XMRIG_FEATURE_BENCHMARK { "stress", 0, nullptr, IConfig::StressKey }, { "bench", 1, nullptr, IConfig::BenchKey }, diff --git a/src/core/config/usage.h b/src/core/config/usage.h index a30ea1331..bf9088481 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -181,6 +181,7 @@ static inline const std::string &usage() u += " --no-title disable setting console window title\n"; # endif u += " --pause-on-battery pause mine on battery power\n"; + u += " --pause-on-active pause mine when mouse or keyboard is touched\n"; # ifdef XMRIG_FEATURE_BENCHMARK u += " --stress run continuous stress test to check system stability\n"; From 3b87cd97cef6f3c47ab1637075def4398f9f62a3 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Wed, 17 Feb 2021 18:05:13 +0200 Subject: [PATCH 03/10] Allow result submission to origin daemon with self-select With `self-select` mode enabled, the `submit-to-origin` config option will let the `SelfSelectClient` submit the solution to both the daemon where it got the template from as well as to the connected pool, for miners that want to do pool minining with Monero and solo mining with an altcoin (merged mining variant). Thank you and special credit to @StriderDM (https://github.com/StriderDM)! --- src/base/io/log/Tags.cpp | 6 +++ src/base/io/log/Tags.h | 1 + src/base/kernel/config/BaseTransform.cpp | 3 ++ src/base/kernel/interfaces/IConfig.h | 1 + src/base/net/stratum/Pool.cpp | 7 ++- src/base/net/stratum/Pool.h | 2 + src/base/net/stratum/SelfSelectClient.cpp | 54 ++++++++++++++++++++++- src/base/net/stratum/SelfSelectClient.h | 13 ++++-- src/config.json | 3 +- src/core/config/Config_default.h | 3 +- src/core/config/Config_platform.h | 1 + src/core/config/usage.h | 1 + 12 files changed, 86 insertions(+), 9 deletions(-) diff --git a/src/base/io/log/Tags.cpp b/src/base/io/log/Tags.cpp index 3960a14df..75b4ca8a3 100644 --- a/src/base/io/log/Tags.cpp +++ b/src/base/io/log/Tags.cpp @@ -36,6 +36,12 @@ const char *xmrig::Tags::network() return tag; } +const char* xmrig::Tags::origin() +{ + static const char* tag = YELLOW_BG_BOLD(WHITE_BOLD_S " origin "); + + return tag; +} const char *xmrig::Tags::signal() { diff --git a/src/base/io/log/Tags.h b/src/base/io/log/Tags.h index 9f690ef2a..fc2c7485a 100644 --- a/src/base/io/log/Tags.h +++ b/src/base/io/log/Tags.h @@ -32,6 +32,7 @@ class Tags public: static const char *config(); static const char *network(); + static const char *origin(); static const char *signal(); # ifdef XMRIG_MINER_PROJECT diff --git a/src/base/kernel/config/BaseTransform.cpp b/src/base/kernel/config/BaseTransform.cpp index 7df0a7952..e6dc4e2e7 100644 --- a/src/base/kernel/config/BaseTransform.cpp +++ b/src/base/kernel/config/BaseTransform.cpp @@ -260,6 +260,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch case IConfig::DryRunKey: /* --dry-run */ case IConfig::HttpEnabledKey: /* --http-enabled */ case IConfig::DaemonKey: /* --daemon */ + case IConfig::SubmitToOriginKey: /* --submit-to-origin */ case IConfig::VerboseKey: /* --verbose */ case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ case IConfig::PauseOnActiveKey: /* --pause-on-active */ @@ -291,6 +292,8 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b case IConfig::TlsKey: /* --tls */ return add(doc, Pools::kPools, Pool::kTls, enable); + case IConfig::SubmitToOriginKey: /* --submit-to-origin */ + return add(doc, Pools::kPools, Pool::kSubmitToOrigin, enable); # ifdef XMRIG_FEATURE_HTTP case IConfig::DaemonKey: /* --daemon */ return add(doc, Pools::kPools, Pool::kDaemon, enable); diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index d5fdb5c92..0e03f7867 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -73,6 +73,7 @@ public: DaemonKey = 1018, DaemonPollKey = 1019, SelfSelectKey = 1028, + SubmitToOriginKey = 1049, DataDirKey = 1035, TitleKey = 1037, NoTitleKey = 1038, diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index f80f1f626..8148deae5 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -79,6 +79,7 @@ const char *Pool::kNicehash = "nicehash"; const char *Pool::kPass = "pass"; const char *Pool::kRigId = "rig-id"; const char *Pool::kSelfSelect = "self-select"; +const char* Pool::kSubmitToOrigin = "submit-to-origin"; const char *Pool::kSOCKS5 = "socks5"; const char *Pool::kTls = "tls"; const char *Pool::kUrl = "url"; @@ -138,6 +139,7 @@ xmrig::Pool::Pool(const rapidjson::Value &object) : if (m_daemon.isValid()) { m_mode = MODE_SELF_SELECT; + m_submit_to_origin = Json::getBool(object, kSubmitToOrigin, false); } else if (Json::getBool(object, kDaemon)) { m_mode = MODE_DAEMON; @@ -237,7 +239,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con client = new DaemonClient(id, listener); } else if (m_mode == MODE_SELF_SELECT) { - client = new SelfSelectClient(id, Platform::userAgent(), listener); + client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submit_to_origin); } # endif # ifdef XMRIG_ALGO_KAWPOW @@ -301,6 +303,7 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const } else { obj.AddMember(StringRef(kSelfSelect), m_daemon.url().toJSON(), allocator); + obj.AddMember(StringRef(kSubmitToOrigin), m_submit_to_origin, allocator); } return obj; @@ -319,7 +322,7 @@ std::string xmrig::Pool::printableName() const } if (m_mode == MODE_SELF_SELECT) { - out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + CLEAR; + out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + WHITE_BOLD_S + (m_submit_to_origin ? " submit-to-origin" : "") + CLEAR; } return out; diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index dc0fec87a..97ef3facb 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -72,6 +72,7 @@ public: static const char *kPass; static const char *kRigId; static const char *kSelfSelect; + static const char* kSubmitToOrigin; static const char *kSOCKS5; static const char *kTls; static const char *kUrl; @@ -156,6 +157,7 @@ private: uint64_t m_pollInterval = kDefaultPollInterval; Url m_daemon; Url m_url; + bool m_submit_to_origin = false; # ifdef XMRIG_FEATURE_BENCHMARK std::shared_ptr m_benchmark; diff --git a/src/base/net/stratum/SelfSelectClient.cpp b/src/base/net/stratum/SelfSelectClient.cpp index fc4cea6e0..b2bb291e6 100644 --- a/src/base/net/stratum/SelfSelectClient.cpp +++ b/src/base/net/stratum/SelfSelectClient.cpp @@ -31,9 +31,12 @@ #include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" +#include "base/io/log/Tags.h" #include "base/net/http/Fetch.h" #include "base/net/http/HttpData.h" #include "base/net/stratum/Client.h" +#include "net/JobResult.h" +#include "base/tools/Cvt.h" namespace xmrig { @@ -54,8 +57,8 @@ static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashin } /* namespace xmrig */ -xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener) : - m_listener(listener) +xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submit_to_origin) : + m_listener(listener), m_submit_to_origin(submit_to_origin) { m_httpListener = std::make_shared(this); m_client = new Client(id, agent, this); @@ -201,6 +204,9 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result) Document doc(kObjectType); auto &allocator = doc.GetAllocator(); + m_blocktemplate = Json::getString(result,kBlocktemplateBlob); + m_blockdiff = Json::getUint64(result, kDifficulty); + Value params(kObjectType); params.AddMember(StringRef(kId), m_job.clientId().toJSON(), allocator); params.AddMember(StringRef(kJobId), m_job.id().toJSON(), allocator); @@ -235,6 +241,50 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result) }); } +int64_t xmrig::SelfSelectClient::submit(const JobResult& result) +{ + if (m_submit_to_origin) { + submitOriginDaemon(result); + } + return m_client->submit(result); +} + +void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result) +{ + if (result.diff == 0 || m_blockdiff == 0) { + return; + } + + if (result.actualDiff() < m_blockdiff) { + m_origin_not_submitted++; + LOG_DEBUG("%s " RED_BOLD("not submitted to origin daemon, difficulty too low") " (%" PRId64 "/%" PRId64 ") " + BLACK_BOLD(" diff ") BLACK_BOLD("%" PRIu64) BLACK_BOLD(" vs. ") BLACK_BOLD("%" PRIu64), + Tags::origin(), m_origin_submitted, m_origin_not_submitted, m_blockdiff, result.actualDiff()); + return; + } + char *data = m_blocktemplate.data(); + Cvt::toHex(data + 78, 8, reinterpret_cast(&result.nonce), 4); + + using namespace rapidjson; + Document doc(kObjectType); + + Value params(kArrayType); + params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator()); + + JsonRequest::create(doc, m_sequence, "submitblock", params); + m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend); + + FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet()); + fetch(tag(), std::move(req), m_httpListener); + + m_origin_submitted++; + LOG_INFO("%s " GREEN_BOLD("submitted to origin daemon") " (%" PRId64 "/%" PRId64 ") " + " diff " WHITE("%" PRIu64) " vs. " WHITE("%" PRIu64), + Tags::origin(), m_origin_submitted, m_origin_not_submitted, m_blockdiff, result.actualDiff(), result.diff); + + // Ensure that the latest block template is available after block submission + getBlockTemplate(); +} void xmrig::SelfSelectClient::onHttpData(const HttpData &data) { diff --git a/src/base/net/stratum/SelfSelectClient.h b/src/base/net/stratum/SelfSelectClient.h index b02e5212e..2cf0e6d03 100644 --- a/src/base/net/stratum/SelfSelectClient.h +++ b/src/base/net/stratum/SelfSelectClient.h @@ -35,6 +35,7 @@ #include +#include namespace xmrig { @@ -45,7 +46,7 @@ class SelfSelectClient : public IClient, public IClientListener, public IHttpLis public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(SelfSelectClient) - SelfSelectClient(int id, const char *agent, IClientListener *listener); + SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submit_to_origin); ~SelfSelectClient() override; protected: @@ -65,7 +66,7 @@ protected: inline int64_t send(const rapidjson::Value &obj, Callback callback) override { return m_client->send(obj, callback); } inline int64_t send(const rapidjson::Value &obj) override { return m_client->send(obj); } inline int64_t sequence() const override { return m_client->sequence(); } - inline int64_t submit(const JobResult &result) override { return m_client->submit(result); } + inline int64_t submit(const JobResult &result) override; inline void connect() override { m_client->connect(); } inline void connect(const Pool &pool) override { m_client->connect(pool); } inline void deleteLater() override { m_client->deleteLater(); } @@ -105,7 +106,7 @@ private: void retry(); void setState(State state); void submitBlockTemplate(rapidjson::Value &result); - + inline void submitOriginDaemon(const JobResult &result); bool m_active = false; bool m_quiet = false; IClient *m_client; @@ -115,9 +116,15 @@ private: int64_t m_sequence = 1; Job m_job; State m_state = IdleState; + String m_blocktemplate; + bool m_submit_to_origin = false; + std::map m_results; std::shared_ptr m_httpListener; uint64_t m_retryPause = 5000; uint64_t m_timestamp = 0; + uint64_t m_blockdiff = 0; + uint64_t m_origin_submitted = 0; + uint64_t m_origin_not_submitted = 0; }; diff --git a/src/config.json b/src/config.json index 7722d19b3..e25c57673 100644 --- a/src/config.json +++ b/src/config.json @@ -75,7 +75,8 @@ "tls-fingerprint": null, "daemon": false, "socks5": null, - "self-select": null + "self-select": null, + "submit-to-origin": false } ], "print-time": 60, diff --git a/src/core/config/Config_default.h b/src/core/config/Config_default.h index c16d421ee..6c46fa956 100644 --- a/src/core/config/Config_default.h +++ b/src/core/config/Config_default.h @@ -105,7 +105,8 @@ R"===( "tls-fingerprint": null, "daemon": false, "socks5": null, - "self-select": null + "self-select": null, + "submit-to-origin": false } ], "print-time": 60, diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index d1b17345f..f97d6fd88 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -57,6 +57,7 @@ static const option options[] = { { "daemon", 0, nullptr, IConfig::DaemonKey }, { "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey }, { "self-select", 1, nullptr, IConfig::SelfSelectKey }, + { "submit-to-origin", 0, nullptr, IConfig::SubmitToOriginKey }, # endif { "av", 1, nullptr, IConfig::AVKey }, { "background", 0, nullptr, IConfig::BackgroundKey }, diff --git a/src/core/config/usage.h b/src/core/config/usage.h index bf9088481..8078e1a43 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -64,6 +64,7 @@ static inline const std::string &usage() u += " --daemon use daemon RPC instead of pool for solo mining\n"; u += " --daemon-poll-interval=N daemon poll interval in milliseconds (default: 1000)\n"; u += " --self-select=URL self-select block templates from URL\n"; + u += " --submit-to-origin also submit solution back to self-select URL\n"; # endif u += " -r, --retries=N number of times to retry before switch to backup server (default: 5)\n"; From 59806758767fa35f78ce5ce59f62bfbd2ae788b9 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 18 Feb 2021 12:56:39 +0700 Subject: [PATCH 04/10] Code and copyright cleanup. --- src/base/io/log/Tags.cpp | 6 ++- src/base/io/log/Tags.h | 4 +- src/base/kernel/interfaces/IConfig.h | 12 ++---- src/base/net/stratum/Pool.cpp | 26 +++++------- src/base/net/stratum/Pool.h | 16 +++----- src/base/net/stratum/SelfSelectClient.cpp | 50 +++++++++++------------ src/base/net/stratum/SelfSelectClient.h | 49 ++++++++++------------ src/core/config/Config_platform.h | 10 +---- src/core/config/usage.h | 15 ++++--- 9 files changed, 80 insertions(+), 108 deletions(-) diff --git a/src/base/io/log/Tags.cpp b/src/base/io/log/Tags.cpp index 75b4ca8a3..23ef63d79 100644 --- a/src/base/io/log/Tags.cpp +++ b/src/base/io/log/Tags.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ const char *xmrig::Tags::network() return tag; } + const char* xmrig::Tags::origin() { static const char* tag = YELLOW_BG_BOLD(WHITE_BOLD_S " origin "); @@ -43,6 +44,7 @@ const char* xmrig::Tags::origin() return tag; } + const char *xmrig::Tags::signal() { static const char *tag = YELLOW_BG_BOLD(WHITE_BOLD_S " signal "); diff --git a/src/base/io/log/Tags.h b/src/base/io/log/Tags.h index fc2c7485a..07312d4e7 100644 --- a/src/base/io/log/Tags.h +++ b/src/base/io/log/Tags.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index 0e03f7867..7a7f657ec 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,7 +67,6 @@ public: DaemonKey = 1018, DaemonPollKey = 1019, SelfSelectKey = 1028, - SubmitToOriginKey = 1049, DataDirKey = 1035, TitleKey = 1037, NoTitleKey = 1038, @@ -88,6 +81,7 @@ public: DmiKey = 1049, HugePageSizeKey = 1050, PauseOnActiveKey = 1051, + SubmitToOriginKey = 1052, // xmrig common CPUPriorityKey = 1021, diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index 8148deae5..e39df3b58 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2020 SChernykh + * Copyright (c) 2016-2020 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -79,8 +73,8 @@ const char *Pool::kNicehash = "nicehash"; const char *Pool::kPass = "pass"; const char *Pool::kRigId = "rig-id"; const char *Pool::kSelfSelect = "self-select"; -const char* Pool::kSubmitToOrigin = "submit-to-origin"; const char *Pool::kSOCKS5 = "socks5"; +const char *Pool::kSubmitToOrigin = "submit-to-origin"; const char *Pool::kTls = "tls"; const char *Pool::kUrl = "url"; const char *Pool::kUser = "user"; @@ -138,8 +132,8 @@ xmrig::Pool::Pool(const rapidjson::Value &object) : setKeepAlive(Json::getValue(object, kKeepalive)); if (m_daemon.isValid()) { - m_mode = MODE_SELF_SELECT; - m_submit_to_origin = Json::getBool(object, kSubmitToOrigin, false); + m_mode = MODE_SELF_SELECT; + m_submitToOrigin = Json::getBool(object, kSubmitToOrigin, m_submitToOrigin); } else if (Json::getBool(object, kDaemon)) { m_mode = MODE_DAEMON; @@ -239,7 +233,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con client = new DaemonClient(id, listener); } else if (m_mode == MODE_SELF_SELECT) { - client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submit_to_origin); + client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submitToOrigin); } # endif # ifdef XMRIG_ALGO_KAWPOW @@ -302,8 +296,8 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const obj.AddMember(StringRef(kDaemonPollInterval), m_pollInterval, allocator); } else { - obj.AddMember(StringRef(kSelfSelect), m_daemon.url().toJSON(), allocator); - obj.AddMember(StringRef(kSubmitToOrigin), m_submit_to_origin, allocator); + obj.AddMember(StringRef(kSelfSelect), m_daemon.url().toJSON(), allocator); + obj.AddMember(StringRef(kSubmitToOrigin), m_submitToOrigin, allocator); } return obj; @@ -322,7 +316,7 @@ std::string xmrig::Pool::printableName() const } if (m_mode == MODE_SELF_SELECT) { - out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + WHITE_BOLD_S + (m_submit_to_origin ? " submit-to-origin" : "") + CLEAR; + out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + WHITE_BOLD_S + (m_submitToOrigin ? " submit-to-origin" : "") + CLEAR; } return out; diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index 97ef3facb..3f9baecf5 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2020 SChernykh + * Copyright (c) 2016-2020 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,8 +66,8 @@ public: static const char *kPass; static const char *kRigId; static const char *kSelfSelect; - static const char* kSubmitToOrigin; static const char *kSOCKS5; + static const char *kSubmitToOrigin; static const char *kTls; static const char *kUrl; static const char *kUser; @@ -145,6 +139,7 @@ private: void setKeepAlive(const rapidjson::Value &value); Algorithm m_algorithm; + bool m_submitToOrigin = false; Coin m_coin; int m_keepAlive = 0; Mode m_mode = MODE_POOL; @@ -157,7 +152,6 @@ private: uint64_t m_pollInterval = kDefaultPollInterval; Url m_daemon; Url m_url; - bool m_submit_to_origin = false; # ifdef XMRIG_FEATURE_BENCHMARK std::shared_ptr m_benchmark; diff --git a/src/base/net/stratum/SelfSelectClient.cpp b/src/base/net/stratum/SelfSelectClient.cpp index b2bb291e6..2dca057ad 100644 --- a/src/base/net/stratum/SelfSelectClient.cpp +++ b/src/base/net/stratum/SelfSelectClient.cpp @@ -1,13 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2019 jtgrassie - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 jtgrassie + * Copyright (c) 2021 Hansie Odendaal + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,8 +52,9 @@ static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashin } /* namespace xmrig */ -xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submit_to_origin) : - m_listener(listener), m_submit_to_origin(submit_to_origin) +xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submitToOrigin) : + m_submitToOrigin(submitToOrigin), + m_listener(listener) { m_httpListener = std::make_shared(this); m_client = new Client(id, agent, this); @@ -71,6 +67,16 @@ xmrig::SelfSelectClient::~SelfSelectClient() } +int64_t xmrig::SelfSelectClient::submit(const JobResult &result) +{ + if (m_submitToOrigin) { + submitOriginDaemon(result); + } + + return m_client->submit(result); +} + + void xmrig::SelfSelectClient::tick(uint64_t now) { m_client->tick(now); @@ -205,7 +211,7 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result) auto &allocator = doc.GetAllocator(); m_blocktemplate = Json::getString(result,kBlocktemplateBlob); - m_blockdiff = Json::getUint64(result, kDifficulty); + m_blockDiff = Json::getUint64(result, kDifficulty); Value params(kObjectType); params.AddMember(StringRef(kId), m_job.clientId().toJSON(), allocator); @@ -241,27 +247,21 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result) }); } -int64_t xmrig::SelfSelectClient::submit(const JobResult& result) -{ - if (m_submit_to_origin) { - submitOriginDaemon(result); - } - return m_client->submit(result); -} void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result) { - if (result.diff == 0 || m_blockdiff == 0) { + if (result.diff == 0 || m_blockDiff == 0) { return; } - if (result.actualDiff() < m_blockdiff) { - m_origin_not_submitted++; + if (result.actualDiff() < m_blockDiff) { + m_originNotSubmitted++; LOG_DEBUG("%s " RED_BOLD("not submitted to origin daemon, difficulty too low") " (%" PRId64 "/%" PRId64 ") " BLACK_BOLD(" diff ") BLACK_BOLD("%" PRIu64) BLACK_BOLD(" vs. ") BLACK_BOLD("%" PRIu64), - Tags::origin(), m_origin_submitted, m_origin_not_submitted, m_blockdiff, result.actualDiff()); + Tags::origin(), m_originSubmitted, m_originNotSubmitted, m_blockDiff, result.actualDiff()); return; } + char *data = m_blocktemplate.data(); Cvt::toHex(data + 78, 8, reinterpret_cast(&result.nonce), 4); @@ -277,10 +277,10 @@ void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result) FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet()); fetch(tag(), std::move(req), m_httpListener); - m_origin_submitted++; + m_originSubmitted++; LOG_INFO("%s " GREEN_BOLD("submitted to origin daemon") " (%" PRId64 "/%" PRId64 ") " " diff " WHITE("%" PRIu64) " vs. " WHITE("%" PRIu64), - Tags::origin(), m_origin_submitted, m_origin_not_submitted, m_blockdiff, result.actualDiff(), result.diff); + Tags::origin(), m_originSubmitted, m_originNotSubmitted, m_blockDiff, result.actualDiff(), result.diff); // Ensure that the latest block template is available after block submission getBlockTemplate(); diff --git a/src/base/net/stratum/SelfSelectClient.h b/src/base/net/stratum/SelfSelectClient.h index 2cf0e6d03..c73198a5a 100644 --- a/src/base/net/stratum/SelfSelectClient.h +++ b/src/base/net/stratum/SelfSelectClient.h @@ -1,13 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2019 jtgrassie - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2019 jtgrassie + * Copyright (c) 2021 Hansie Odendaal + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,11 +26,10 @@ #include "base/kernel/interfaces/IClientListener.h" #include "base/net/http/HttpListener.h" #include "base/net/stratum/Job.h" -#include "base/tools/Object.h" -#include #include +#include namespace xmrig { @@ -46,7 +40,7 @@ class SelfSelectClient : public IClient, public IClientListener, public IHttpLis public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(SelfSelectClient) - SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submit_to_origin); + SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submitToOrigin); ~SelfSelectClient() override; protected: @@ -66,7 +60,6 @@ protected: inline int64_t send(const rapidjson::Value &obj, Callback callback) override { return m_client->send(obj, callback); } inline int64_t send(const rapidjson::Value &obj) override { return m_client->send(obj); } inline int64_t sequence() const override { return m_client->sequence(); } - inline int64_t submit(const JobResult &result) override; inline void connect() override { m_client->connect(); } inline void connect(const Pool &pool) override { m_client->connect(pool); } inline void deleteLater() override { m_client->deleteLater(); } @@ -78,6 +71,7 @@ protected: inline void setRetries(int retries) override { m_client->setRetries(retries); m_retries = retries; } inline void setRetryPause(uint64_t ms) override { m_client->setRetryPause(ms); m_retryPause = ms; } + int64_t submit(const JobResult &result) override; void tick(uint64_t now) override; // IClientListener @@ -106,25 +100,26 @@ private: void retry(); void setState(State state); void submitBlockTemplate(rapidjson::Value &result); - inline void submitOriginDaemon(const JobResult &result); - bool m_active = false; - bool m_quiet = false; + void submitOriginDaemon(const JobResult &result); + + bool m_active = false; + bool m_quiet = false; + const bool m_submitToOrigin; IClient *m_client; IClientListener *m_listener; - int m_retries = 5; - int64_t m_failures = 0; - int64_t m_sequence = 1; + int m_retries = 5; + int64_t m_failures = 0; + int64_t m_sequence = 1; Job m_job; - State m_state = IdleState; - String m_blocktemplate; - bool m_submit_to_origin = false; + State m_state = IdleState; std::map m_results; std::shared_ptr m_httpListener; - uint64_t m_retryPause = 5000; - uint64_t m_timestamp = 0; - uint64_t m_blockdiff = 0; - uint64_t m_origin_submitted = 0; - uint64_t m_origin_not_submitted = 0; + String m_blocktemplate; + uint64_t m_blockDiff = 0; + uint64_t m_originNotSubmitted = 0; + uint64_t m_originSubmitted = 0; + uint64_t m_retryPause = 5000; + uint64_t m_timestamp = 0; }; diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index f97d6fd88..dbe2a4d81 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 8078e1a43..8b8ec533a 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -1,12 +1,11 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2010 Jeff Garzik + * Copyright (c) 2012-2014 pooler + * Copyright (c) 2014 Lucas Jones + * Copyright (c) 2014-2016 Wolf9466 + * Copyright (c) 2016 Jay D Dee + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From d1d1517b4fa3f4dde1304b79d18e9af134e3913c Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 18 Feb 2021 15:22:39 +0700 Subject: [PATCH 05/10] Fixed macOS build. --- src/base/kernel/Platform_mac.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 20ad96529..7715b8d7e 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -107,3 +107,10 @@ bool xmrig::Platform::isOnBatteryPower() { return IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited; } + + +bool xmrig::Platform::isUserActive() +{ + // TODO + return false; +} From e8a99809b66435590067865053215bb394f342b5 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 18 Feb 2021 14:49:37 +0100 Subject: [PATCH 06/10] Fixed crash when GPU mining cn-heavy on Zen3 system --- src/backend/cpu/CpuWorker.cpp | 2 +- src/crypto/cn/CnHash.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 794d773ff..aed79190a 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -83,7 +83,7 @@ xmrig::CpuWorker::CpuWorker(size_t id, const CpuLaunchData &data) : { # ifdef XMRIG_ALGO_CN_HEAVY // cn-heavy optimization for Zen3 CPUs - if ((N == 1) && (m_av == CnHash::AV_SINGLE) && (m_algorithm.family() == Algorithm::CN_HEAVY) && (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3)) { + if ((N == 1) && (m_av == CnHash::AV_SINGLE) && (m_algorithm.family() == Algorithm::CN_HEAVY) && (m_assembly != Assembly::NONE) && (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3)) { std::lock_guard lock(cn_heavyZen3MemoryMutex); if (!cn_heavyZen3Memory) { cn_heavyZen3Memory = new VirtualMemory(m_algorithm.l3() * m_threads, data.hugePages, false, false, node()); diff --git a/src/crypto/cn/CnHash.cpp b/src/crypto/cn/CnHash.cpp index 89caa1b02..c975190cb 100644 --- a/src/crypto/cn/CnHash.cpp +++ b/src/crypto/cn/CnHash.cpp @@ -300,7 +300,7 @@ xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, # ifdef XMRIG_ALGO_CN_HEAVY // cn-heavy optimization for Zen3 CPUs - if ((av == AV_SINGLE) && (xmrig::Cpu::info()->arch() == xmrig::ICpuInfo::ARCH_ZEN3)) { + if ((av == AV_SINGLE) && (assembly != Assembly::NONE) && (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3)) { switch (algorithm.id()) { case xmrig::Algorithm::CN_HEAVY_0: return cryptonight_single_hash; From f599807bbb92ea46f1c2a48934fd3853b780f391 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 19 Feb 2021 16:26:31 +0700 Subject: [PATCH 07/10] Simplified code, fixed broken pause. --- src/core/Miner.cpp | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 6b3a74ba8..60cc79666 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -628,34 +628,24 @@ void xmrig::Miner::onTimer(const Timer *) d_ptr->ticks++; + auto autoPause = [this](bool &state, bool pause, const char *pauseMessage, const char *activeMessage) + { + if ((pause && !state) || (!pause && state)) { + LOG_INFO("%s %s", Tags::miner(), pause ? pauseMessage : activeMessage); + + state = pause; + setEnabled(!pause); + } + }; + if (d_ptr->controller->config()->isPauseOnBattery()) { - const bool battery_power = Platform::isOnBatteryPower(); - if (battery_power && !d_ptr->battery_power) { - LOG_INFO("%s " YELLOW_BOLD("on battery power"), Tags::miner()); - d_ptr->battery_power = true; - } - else if (!battery_power && d_ptr->battery_power) { - LOG_INFO("%s " GREEN_BOLD("on AC power"), Tags::miner()); - d_ptr->battery_power = false; - } + autoPause(d_ptr->battery_power, Platform::isOnBatteryPower(), YELLOW_BOLD("on battery power"), GREEN_BOLD("on AC power")); } if (d_ptr->controller->config()->isPauseOnActive()) { - const bool user_active = Platform::isUserActive(); - if (user_active && !d_ptr->user_active) { - LOG_INFO("%s " YELLOW_BOLD("user active"), Tags::miner()); - d_ptr->user_active = true; - } - else if (!user_active && d_ptr->user_active) { - LOG_INFO("%s " GREEN_BOLD("user inactive"), Tags::miner()); - d_ptr->user_active = false; - } + autoPause(d_ptr->user_active, Platform::isUserActive(), YELLOW_BOLD("user active"), GREEN_BOLD("user inactive")); } - const bool batteryEnabled = !(d_ptr->controller->config()->isPauseOnBattery() && d_ptr->battery_power); - const bool userActiveEnabled = !(d_ptr->controller->config()->isPauseOnActive() && d_ptr->user_active); - setEnabled(batteryEnabled && userActiveEnabled); - if (stopMiner) { stop(); } From ee341118ce43fc9eea057090d55822f133f9c5f3 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 19 Feb 2021 23:35:30 +0700 Subject: [PATCH 08/10] #2104 Added user configurable idle time. --- src/base/kernel/Platform.cpp | 4 +- src/base/kernel/Platform.h | 9 +++-- src/base/kernel/Platform_mac.cpp | 10 ++--- src/base/kernel/Platform_unix.cpp | 10 ++--- src/base/kernel/Platform_win.cpp | 13 ++++--- src/base/kernel/config/BaseConfig.cpp | 14 +------ src/base/kernel/config/BaseConfig.h | 18 ++------- src/base/kernel/config/BaseTransform.cpp | 18 +-------- src/base/kernel/config/BaseTransform.h | 10 +---- src/core/Miner.cpp | 11 +++--- src/core/config/Config.cpp | 49 +++++++++++++++++++----- src/core/config/Config.h | 17 ++++---- src/core/config/ConfigTransform.cpp | 16 ++++---- src/core/config/ConfigTransform.h | 10 +---- src/core/config/Config_platform.h | 2 +- src/core/config/usage.h | 2 +- 16 files changed, 99 insertions(+), 114 deletions(-) diff --git a/src/base/kernel/Platform.cpp b/src/base/kernel/Platform.cpp index 955a4eac6..ef2b67eb9 100644 --- a/src/base/kernel/Platform.cpp +++ b/src/base/kernel/Platform.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index f38804896..04c212e64 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/Platform.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,10 +46,11 @@ public: static void setProcessPriority(int priority); static void setThreadPriority(int priority); - static inline const String &userAgent() { return m_userAgent; } + static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; } + static inline const String &userAgent() { return m_userAgent; } static bool isOnBatteryPower(); - static bool isUserActive(); + static uint64_t idleTime(); private: static char *createUserAgent(); diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 7715b8d7e..efbbf3ad6 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include #include #include +#include #include "base/kernel/Platform.h" @@ -109,8 +110,7 @@ bool xmrig::Platform::isOnBatteryPower() } -bool xmrig::Platform::isUserActive() +uint64_t xmrig::Platform::idleTime() { - // TODO - return false; + return std::numeric_limits::max(); } diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index cf7d37ca3..f5bbc1931 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ #include #include #include +#include #include "base/kernel/Platform.h" @@ -160,8 +161,7 @@ bool xmrig::Platform::isOnBatteryPower() } -bool xmrig::Platform::isUserActive() +uint64_t xmrig::Platform::idleTime() { - // TODO - return false; + return std::numeric_limits::max(); } diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index 7667691b0..75f810419 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh - * Copyright (c) 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include #include #include +#include #include "base/kernel/Platform.h" @@ -163,14 +164,14 @@ bool xmrig::Platform::isOnBatteryPower() } -bool xmrig::Platform::isUserActive() +uint64_t xmrig::Platform::idleTime() { - LASTINPUTINFO info; + LASTINPUTINFO info{}; info.cbSize = sizeof(LASTINPUTINFO); if (!GetLastInputInfo(&info)) { - return false; + return std::numeric_limits::max(); } - return static_cast(GetTickCount() - info.dwTime) < 60 * 1000; + return static_cast(GetTickCount() - info.dwTime); } diff --git a/src/base/kernel/config/BaseConfig.cpp b/src/base/kernel/config/BaseConfig.cpp index c2f4196e3..1f2b09cb2 100644 --- a/src/base/kernel/config/BaseConfig.cpp +++ b/src/base/kernel/config/BaseConfig.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,8 +55,6 @@ 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::kPauseOnActive = "pause-on-active"; const char *BaseConfig::kPrintTime = "print-time"; const char *BaseConfig::kSyslog = "syslog"; const char *BaseConfig::kTitle = "title"; @@ -92,8 +84,6 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName) m_dryRun = reader.getBool(kDryRun, m_dryRun); m_syslog = reader.getBool(kSyslog, m_syslog); m_watch = reader.getBool(kWatch, m_watch); - m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery); - m_pauseOnActive = reader.getBool(kPauseOnActive, m_pauseOnActive); m_logFile = reader.getString(kLogFile); m_userAgent = reader.getString(kUserAgent); m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U); diff --git a/src/base/kernel/config/BaseConfig.h b/src/base/kernel/config/BaseConfig.h index 4f28cadf6..37d4641f0 100644 --- a/src/base/kernel/config/BaseConfig.h +++ b/src/base/kernel/config/BaseConfig.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,8 +49,6 @@ public: static const char *kDryRun; static const char *kHttp; static const char *kLogFile; - static const char *kPauseOnBattery; - static const char *kPauseOnActive; static const char *kPrintTime; static const char *kSyslog; static const char *kTitle; @@ -73,8 +65,6 @@ 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 isPauseOnActive() const { return m_pauseOnActive; } 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(); } @@ -102,8 +92,6 @@ protected: bool m_autoSave = true; bool m_background = false; bool m_dryRun = false; - bool m_pauseOnBattery = false; - bool m_pauseOnActive = false; bool m_syslog = false; bool m_upgrade = false; bool m_watch = true; @@ -115,7 +103,7 @@ protected: String m_logFile; String m_userAgent; Title m_title; - uint32_t m_printTime = 60; + uint32_t m_printTime = 60; # ifdef XMRIG_FEATURE_TLS TlsConfig m_tls; diff --git a/src/base/kernel/config/BaseTransform.cpp b/src/base/kernel/config/BaseTransform.cpp index e6dc4e2e7..55e082b61 100644 --- a/src/base/kernel/config/BaseTransform.cpp +++ b/src/base/kernel/config/BaseTransform.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -262,8 +256,6 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch case IConfig::DaemonKey: /* --daemon */ case IConfig::SubmitToOriginKey: /* --submit-to-origin */ case IConfig::VerboseKey: /* --verbose */ - case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ - case IConfig::PauseOnActiveKey: /* --pause-on-active */ return transformBoolean(doc, key, true); case IConfig::ColorKey: /* --no-color */ @@ -324,12 +316,6 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b case IConfig::NoTitleKey: /* --no-title */ return set(doc, BaseConfig::kTitle, enable); - case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ - return set(doc, BaseConfig::kPauseOnBattery, enable); - - case IConfig::PauseOnActiveKey: /* --pause-on-active */ - return set(doc, BaseConfig::kPauseOnActive, enable); - default: break; } diff --git a/src/base/kernel/config/BaseTransform.h b/src/base/kernel/config/BaseTransform.h index d6c08821b..0ddcebc86 100644 --- a/src/base/kernel/config/BaseTransform.h +++ b/src/base/kernel/config/BaseTransform.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 60cc79666..b9e4fbad2 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -601,7 +601,8 @@ void xmrig::Miner::onConfigChanged(Config *config, Config *previousConfig) void xmrig::Miner::onTimer(const Timer *) { double maxHashrate = 0.0; - const auto healthPrintTime = d_ptr->controller->config()->healthPrintTime(); + const auto config = d_ptr->controller->config(); + const auto healthPrintTime = config->healthPrintTime(); bool stopMiner = false; @@ -621,7 +622,7 @@ void xmrig::Miner::onTimer(const Timer *) d_ptr->maxHashrate[d_ptr->algorithm] = std::max(d_ptr->maxHashrate[d_ptr->algorithm], maxHashrate); - const auto printTime = d_ptr->controller->config()->printTime(); + const auto printTime = config->printTime(); if (printTime && d_ptr->ticks && (d_ptr->ticks % (printTime * 2)) == 0) { d_ptr->printHashrate(false); } @@ -638,12 +639,12 @@ void xmrig::Miner::onTimer(const Timer *) } }; - if (d_ptr->controller->config()->isPauseOnBattery()) { + if (config->isPauseOnBattery()) { autoPause(d_ptr->battery_power, Platform::isOnBatteryPower(), YELLOW_BOLD("on battery power"), GREEN_BOLD("on AC power")); } - if (d_ptr->controller->config()->isPauseOnActive()) { - autoPause(d_ptr->user_active, Platform::isUserActive(), YELLOW_BOLD("user active"), GREEN_BOLD("user inactive")); + if (config->isPauseOnActive()) { + autoPause(d_ptr->user_active, Platform::isUserActive(config->idleTime()), YELLOW_BOLD("user active"), GREEN_BOLD("user inactive")); } if (stopMiner) { diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index f2a0c4a93..2b27ae58d 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +16,7 @@ * along with this program. If not, see . */ + #include #include #include @@ -54,6 +49,13 @@ namespace xmrig { +constexpr static uint32_t kIdleTime = 60U; + + +const char *Config::kPauseOnBattery = "pause-on-battery"; +const char *Config::kPauseOnActive = "pause-on-active"; + + #ifdef XMRIG_FEATURE_OPENCL const char *Config::kOcl = "opencl"; #endif @@ -74,7 +76,9 @@ const char *Config::kDMI = "dmi"; class ConfigPrivate { public: + bool pauseOnBattery = false; CpuConfig cpu; + uint32_t idleTime = 0; # ifdef XMRIG_ALGO_RANDOMX RxConfig rx; @@ -89,12 +93,22 @@ public: # endif # if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) - uint32_t healthPrintTime = 60; + uint32_t healthPrintTime = 60U; # endif # ifdef XMRIG_FEATURE_DMI bool dmi = true; # endif + + void setIdleTime(const rapidjson::Value &value) + { + if (value.IsBool()) { + idleTime = value.GetBool() ? kIdleTime : 0U; + } + else if (value.IsUint()) { + idleTime = value.GetUint(); + } + } }; } @@ -112,12 +126,24 @@ xmrig::Config::~Config() } +bool xmrig::Config::isPauseOnBattery() const +{ + return d_ptr->pauseOnBattery; +} + + const xmrig::CpuConfig &xmrig::Config::cpu() const { return d_ptr->cpu; } +uint32_t xmrig::Config::idleTime() const +{ + return d_ptr->idleTime * 1000U; +} + + #ifdef XMRIG_FEATURE_OPENCL const xmrig::OclConfig &xmrig::Config::cl() const { @@ -186,6 +212,9 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName) return false; } + d_ptr->pauseOnBattery = reader.getBool(kPauseOnBattery, d_ptr->pauseOnBattery); + d_ptr->setIdleTime(reader.getValue(kPauseOnActive)); + d_ptr->cpu.read(reader.getValue(CpuConfig::kField)); # ifdef XMRIG_ALGO_RANDOMX @@ -270,5 +299,5 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator); doc.AddMember(StringRef(kWatch), m_watch, allocator); doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator); - doc.AddMember(StringRef(kPauseOnActive), isPauseOnActive(), allocator); + doc.AddMember(StringRef(kPauseOnActive), (d_ptr->idleTime == 0U || d_ptr->idleTime == kIdleTime) ? Value(isPauseOnActive()) : Value(d_ptr->idleTime), allocator); } diff --git a/src/core/config/Config.h b/src/core/config/Config.h index d8433beb2..c2da8523d 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +44,9 @@ class Config : public BaseConfig public: XMRIG_DISABLE_COPY_MOVE(Config); + static const char *kPauseOnBattery; + static const char *kPauseOnActive; + # ifdef XMRIG_FEATURE_OPENCL static const char *kOcl; # endif @@ -69,7 +66,11 @@ public: Config(); ~Config() override; + inline bool isPauseOnActive() const { return idleTime() > 0; } + + bool isPauseOnBattery() const; const CpuConfig &cpu() const; + uint32_t idleTime() const; # ifdef XMRIG_FEATURE_OPENCL const OclConfig &cl() const; diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index 7140837a1..dce9d326f 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -150,6 +144,12 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const case IConfig::YieldKey: /* --cpu-no-yield */ return set(doc, CpuConfig::kField, CpuConfig::kYield, false); + case IConfig::PauseOnBatteryKey: /* --pause-on-battery */ + return set(doc, Config::kPauseOnBattery, true); + + case IConfig::PauseOnActiveKey: /* --pause-on-active */ + return set(doc, Config::kPauseOnActive, static_cast(strtol(arg, nullptr, 10))); + # ifdef XMRIG_ALGO_ARGON2 case IConfig::Argon2ImplKey: /* --argon2-impl */ return set(doc, CpuConfig::kField, CpuConfig::kArgon2Impl, arg); diff --git a/src/core/config/ConfigTransform.h b/src/core/config/ConfigTransform.h index 8fd2505ce..db25b0a08 100644 --- a/src/core/config/ConfigTransform.h +++ b/src/core/config/ConfigTransform.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright (c) 2018-2021 SChernykh + * Copyright (c) 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index dbe2a4d81..d54299753 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -93,7 +93,7 @@ static const option options[] = { { "title", 1, nullptr, IConfig::TitleKey }, { "no-title", 0, nullptr, IConfig::NoTitleKey }, { "pause-on-battery", 0, nullptr, IConfig::PauseOnBatteryKey }, - { "pause-on-active", 0, nullptr, IConfig::PauseOnActiveKey }, + { "pause-on-active", 1, nullptr, IConfig::PauseOnActiveKey }, # ifdef XMRIG_FEATURE_BENCHMARK { "stress", 0, nullptr, IConfig::StressKey }, { "bench", 1, nullptr, IConfig::BenchKey }, diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 8b8ec533a..fb8872065 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -181,7 +181,7 @@ static inline const std::string &usage() u += " --no-title disable setting console window title\n"; # endif u += " --pause-on-battery pause mine on battery power\n"; - u += " --pause-on-active pause mine when mouse or keyboard is touched\n"; + u += " --pause-on-active=N pause mine when the user is active (resume after N seconds of last activity)\n"; # ifdef XMRIG_FEATURE_BENCHMARK u += " --stress run continuous stress test to check system stability\n"; From b49fb27e8471f8690858dd1a37c99d4f23b2f674 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 20 Feb 2021 13:18:31 +0700 Subject: [PATCH 09/10] Added idle time detection for macOS. --- CMakeLists.txt | 4 +++- src/base/kernel/Platform_mac.cpp | 12 ++++++++++-- src/hw/dmi/dmi.cmake | 2 -- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a927ab73..c1f403af7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,8 +147,10 @@ elseif (XMRIG_OS_APPLE) src/App_unix.cpp src/crypto/common/VirtualMemory_unix.cpp ) + find_library(IOKIT_LIBRARY IOKit) - set(EXTRA_LIBS ${IOKIT_LIBRARY}) + find_library(CORESERVICES_LIBRARY CoreServices) + set(EXTRA_LIBS ${IOKIT_LIBRARY} ${CORESERVICES_LIBRARY}) else() list(APPEND SOURCES_OS src/App_unix.cpp diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index efbbf3ad6..d07e925d4 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include "base/kernel/Platform.h" @@ -112,5 +111,14 @@ bool xmrig::Platform::isOnBatteryPower() uint64_t xmrig::Platform::idleTime() { - return std::numeric_limits::max(); + uint64_t idle_time = 0; + const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem")); + const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0); + + CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time); + + CFRelease(property); + IOObjectRelease(service); + + return idle_time / 1000000U; } diff --git a/src/hw/dmi/dmi.cmake b/src/hw/dmi/dmi.cmake index b6f91616b..27c2f7d3e 100644 --- a/src/hw/dmi/dmi.cmake +++ b/src/hw/dmi/dmi.cmake @@ -27,8 +27,6 @@ if (WITH_DMI) list(APPEND SOURCES src/hw/dmi/DmiReader_unix.cpp) elseif(XMRIG_OS_MACOS) list(APPEND SOURCES src/hw/dmi/DmiReader_mac.cpp) - find_library(CORESERVICES_LIBRARY CoreServices) - list(APPEND EXTRA_LIBS ${CORESERVICES_LIBRARY}) endif() else() remove_definitions(/DXMRIG_FEATURE_DMI) From 4b1857114ee0fdadce7a72494f0e502e452e6ce1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 20 Feb 2021 14:28:20 +0700 Subject: [PATCH 10/10] v6.9.0-dev --- CHANGELOG.md | 5 +++++ README.md | 2 +- src/version.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee596c3b5..4a137cf95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v6.9.0 +- [#2104](https://github.com/xmrig/xmrig/pull/2104) Added [pause-on-active](https://xmrig.com/docs/miner/config/misc#pause-on-active) config option and `--pause-on-active=N` command line option. +- [#2112](https://github.com/xmrig/xmrig/pull/2112) Added support for [Tari merge mining](https://github.com/tari-project/tari/blob/development/README.md#tari-merge-mining). +- [#2117](https://github.com/xmrig/xmrig/pull/2117) Fixed crash when GPU mining `cn-heavy` on Zen3 system. + # v6.8.2 - [#2080](https://github.com/xmrig/xmrig/pull/2080) Fixed compile error in Termux. - [#2089](https://github.com/xmrig/xmrig/pull/2089) Optimized CryptoNight-Heavy for Zen3, 7-8% speedup. diff --git a/README.md b/README.md index 6596983e5..dddb39608 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ XMRig is a high performance, open source, cross platform RandomX, KawPow, Crypto * **[Build from source](https://xmrig.com/docs/miner/build)** ## Usage -The preferred way to configure the miner is the [JSON config file](src/config.json) as it is more flexible and human friendly. The [command line interface](https://xmrig.com/docs/miner/command-line-options) does not cover all features, such as mining profiles for different algorithms. Important options can be changed during runtime without miner restart by editing the config file or executing API calls. +The preferred way to configure the miner is the [JSON config file](https://xmrig.com/docs/miner/config) as it is more flexible and human friendly. The [command line interface](https://xmrig.com/docs/miner/command-line-options) does not cover all features, such as mining profiles for different algorithms. Important options can be changed during runtime without miner restart by editing the config file or executing [API](https://xmrig.com/docs/miner/api) calls. * **[Wizard](https://xmrig.com/wizard)** helps you create initial configuration for the miner. * **[Workers](http://workers.xmrig.info)** helps manage your miners via HTTP API. diff --git a/src/version.h b/src/version.h index e0fd2f58a..7afa0c67a 100644 --- a/src/version.h +++ b/src/version.h @@ -28,15 +28,15 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.8.3-dev" +#define APP_VERSION "6.9.0-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" #define APP_KIND "miner" #define APP_VER_MAJOR 6 -#define APP_VER_MINOR 8 -#define APP_VER_PATCH 3 +#define APP_VER_MINOR 9 +#define APP_VER_PATCH 0 #ifdef _MSC_VER # if (_MSC_VER >= 1920)