From 58711aa66638420e5bc4ededb28e963856a5a9f7 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 25 Nov 2020 21:12:45 +0700 Subject: [PATCH 1/6] v6.6.2-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 848c6371..14fee8ea 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.6.1" +#define APP_VERSION "6.6.2-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2020 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 6 -#define APP_VER_PATCH 1 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From fb9d2b9e7c162a93c8e13628c3000958a6b1aa52 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 26 Nov 2020 18:50:46 +0100 Subject: [PATCH 2/6] Example mining scripts to help new miners --- CMakeLists.txt | 2 ++ scripts/pool_mine_example.cmd | 19 +++++++++++++++++++ scripts/solo_mine_example.cmd | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 scripts/pool_mine_example.cmd create mode 100644 scripts/solo_mine_example.cmd diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b635692..5b095f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,8 @@ if (WIN32) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/bin/WinRing0/WinRing0x64.sys" $) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_1M.cmd" $) add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/benchmark_10M.cmd" $) + add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/pool_mine_example.cmd" $) + add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/scripts/solo_mine_example.cmd" $) endif() if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_BUILD_TYPE STREQUAL Release) diff --git a/scripts/pool_mine_example.cmd b/scripts/pool_mine_example.cmd new file mode 100644 index 00000000..27749ef6 --- /dev/null +++ b/scripts/pool_mine_example.cmd @@ -0,0 +1,19 @@ +:: Example batch file for mining Monero at a pool +:: +:: Format: +:: xmrig.exe -o : -u -p +:: +:: Fields: +:: pool address The host name of the pool stratum or its IP address, for example pool.hashvault.pro +:: pool port The port of the pool's stratum to connect to, for example 3333. Check your pool's getting started page. +:: pool username/wallet For most pools, this is the wallet address you want to mine to. Some pools require a username +:: pool password For most pools this can be just 'x'. For pools using usernames, you may need to provide a password as configured on the pool. +:: +:: List of Monero mining pools: +:: https://miningpoolstats.stream/monero +:: +:: Choose pools outside of top 5 to help Monero network be more decentralized! +:: Smaller pools also often have smaller fees/payout limits. + +xmrig.exe -o pool.hashvault.pro:3333 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD -p x +pause diff --git a/scripts/solo_mine_example.cmd b/scripts/solo_mine_example.cmd new file mode 100644 index 00000000..151ecc5d --- /dev/null +++ b/scripts/solo_mine_example.cmd @@ -0,0 +1,15 @@ +:: Example batch file for mining Monero solo +:: +:: Format: +:: xmrig.exe -o : -a rx/0 -u --daemon +:: +:: Fields: +:: node address The host name of your monerod node or its IP address. It can also be a public node with RPC enabled, for example node.xmr.to +:: node port The RPC port of your monerod node to connect to, usually 18081. +:: wallet address Check your Monero CLI or GUI wallet to see your wallet's address. +:: +:: Mining solo is the best way to help Monero network be more decentralized! +:: But you will only get a payout when you find a block which can take more than a year for a single low-end PC. + +xmrig.exe -o node.xmr.to:18081 -a rx/0 -u 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD --daemon +pause From 096b09bf4d3e68961731a969eb84288153a81046 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 29 Nov 2020 18:45:52 +0700 Subject: [PATCH 3/6] Update base --- src/base/io/Env.cpp | 28 +++++++------ src/base/io/Env.h | 17 ++++---- src/base/kernel/Platform.cpp | 10 +---- src/base/kernel/Platform.h | 12 ++---- src/base/kernel/Platform_hwloc.cpp | 11 +---- src/base/kernel/Platform_mac.cpp | 9 +---- src/base/kernel/Platform_unix.cpp | 9 +---- src/base/kernel/Platform_win.cpp | 9 +---- src/base/kernel/interfaces/IConsoleListener.h | 16 ++++---- src/base/kernel/interfaces/IDnsListener.h | 16 ++++---- src/base/kernel/interfaces/IHttpListener.h | 18 ++++----- src/base/kernel/interfaces/ISignalListener.h | 18 ++++----- src/base/kernel/interfaces/ITimerListener.h | 18 ++++----- src/base/net/http/HttpClient.cpp | 2 +- src/base/tools/Arguments.cpp | 10 +---- src/base/tools/Arguments.h | 10 +---- src/base/tools/Baton.h | 10 +---- src/base/tools/Chrono.h | 10 +---- src/base/tools/Handle.h | 10 +---- src/base/tools/Object.h | 10 +---- src/base/tools/String.cpp | 40 ++++++++++++------- src/base/tools/String.h | 16 +++----- src/core/Miner.cpp | 2 +- 23 files changed, 124 insertions(+), 187 deletions(-) diff --git a/src/base/io/Env.cpp b/src/base/io/Env.cpp index ae1c27b5..de93c102 100644 --- a/src/base/io/Env.cpp +++ b/src/base/io/Env.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-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,7 +66,7 @@ static void createVariables() } // namespace xmrig -xmrig::String xmrig::Env::expand(const char *in) +xmrig::String xmrig::Env::expand(const char *in, const std::map &extra) { # ifdef XMRIG_FEATURE_ENV if (in == nullptr) { @@ -96,7 +90,7 @@ xmrig::String xmrig::Env::expand(const char *in) continue; } - vars.insert({ var, get(m[1].str().c_str()) }); + vars.insert({ var, get(m[1].str().c_str(), extra) }); } for (const auto &kv : vars) { @@ -118,15 +112,23 @@ xmrig::String xmrig::Env::expand(const char *in) } -xmrig::String xmrig::Env::get(const String &name) +xmrig::String xmrig::Env::get(const String &name, const std::map &extra) { # ifdef XMRIG_FEATURE_ENV if (variables.empty()) { createVariables(); } - if (variables.count(name)) { - return variables.at(name); + const auto it = variables.find(name); + if (it != variables.end()) { + return it->second; + } + + if (!extra.empty()) { + const auto it = extra.find(name); + if (it != extra.end()) { + return it->second; + } } # endif diff --git a/src/base/io/Env.h b/src/base/io/Env.h index dd06297d..ba7017da 100644 --- a/src/base/io/Env.h +++ b/src/base/io/Env.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-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 @@ -29,14 +23,17 @@ #include "base/tools/String.h" +#include + + namespace xmrig { class Env { public: - static String expand(const char *in); - static String get(const String &name); + static String expand(const char *in, const std::map &extra = {}); + static String get(const String &name, const std::map &extra = {}); static String hostname(); }; diff --git a/src/base/kernel/Platform.cpp b/src/base/kernel/Platform.cpp index 67c72923..955a4eac 100644 --- a/src/base/kernel/Platform.cpp +++ b/src/base/kernel/Platform.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index b56c214d..293cedc7 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/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-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 @@ -52,7 +46,7 @@ public: static void setProcessPriority(int priority); static void setThreadPriority(int priority); - static inline const char *userAgent() { return m_userAgent; } + static inline const String &userAgent() { return m_userAgent; } static bool isOnBatteryPower(); diff --git a/src/base/kernel/Platform_hwloc.cpp b/src/base/kernel/Platform_hwloc.cpp index ca5bfed2..8ec06975 100644 --- a/src/base/kernel/Platform_hwloc.cpp +++ b/src/base/kernel/Platform_hwloc.cpp @@ -1,13 +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 Lee Clagett - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * 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 diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 8ffae1e1..27797ff7 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -1,11 +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 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * 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 diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index f0b382c0..bbded9f6 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -1,11 +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 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * 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 diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index 89f26a07..a487e17b 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -1,11 +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 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * 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 diff --git a/src/base/kernel/interfaces/IConsoleListener.h b/src/base/kernel/interfaces/IConsoleListener.h index 88972f05..69433210 100644 --- a/src/base/kernel/interfaces/IConsoleListener.h +++ b/src/base/kernel/interfaces/IConsoleListener.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 @@ -26,12 +20,18 @@ #define XMRIG_ICONSOLELISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { class IConsoleListener { public: + XMRIG_DISABLE_COPY_MOVE(IConsoleListener) + + IConsoleListener() = default; virtual ~IConsoleListener() = default; virtual void onConsoleCommand(char command) = 0; diff --git a/src/base/kernel/interfaces/IDnsListener.h b/src/base/kernel/interfaces/IDnsListener.h index 4cbb3f7e..7d0e14e3 100644 --- a/src/base/kernel/interfaces/IDnsListener.h +++ b/src/base/kernel/interfaces/IDnsListener.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-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 @@ -26,6 +20,9 @@ #define XMRIG_IDNSLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -35,6 +32,9 @@ class Dns; class IDnsListener { public: + XMRIG_DISABLE_COPY_MOVE(IDnsListener) + + IDnsListener() = default; virtual ~IDnsListener() = default; virtual void onResolved(const Dns &dns, int status) = 0; diff --git a/src/base/kernel/interfaces/IHttpListener.h b/src/base/kernel/interfaces/IHttpListener.h index 94fd1d18..931d1933 100644 --- a/src/base/kernel/interfaces/IHttpListener.h +++ b/src/base/kernel/interfaces/IHttpListener.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 @@ -26,6 +20,9 @@ #define XMRIG_IHTTPLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -36,7 +33,10 @@ class HttpResponse; class IHttpListener { public: - virtual ~IHttpListener() = default; + XMRIG_DISABLE_COPY_MOVE(IHttpListener) + + IHttpListener() = default; + virtual ~IHttpListener() = default; virtual void onHttpData(const HttpData &data) = 0; }; diff --git a/src/base/kernel/interfaces/ISignalListener.h b/src/base/kernel/interfaces/ISignalListener.h index bbcd11f1..75f47cf0 100644 --- a/src/base/kernel/interfaces/ISignalListener.h +++ b/src/base/kernel/interfaces/ISignalListener.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 @@ -26,6 +20,9 @@ #define XMRIG_ISIGNALLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -35,7 +32,10 @@ class String; class ISignalListener { public: - virtual ~ISignalListener() = default; + XMRIG_DISABLE_COPY_MOVE(ISignalListener) + + ISignalListener() = default; + virtual ~ISignalListener() = default; virtual void onSignal(int signum) = 0; }; diff --git a/src/base/kernel/interfaces/ITimerListener.h b/src/base/kernel/interfaces/ITimerListener.h index 1b6337d6..d169b12e 100644 --- a/src/base/kernel/interfaces/ITimerListener.h +++ b/src/base/kernel/interfaces/ITimerListener.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 @@ -26,6 +20,9 @@ #define XMRIG_ITIMERLISTENER_H +#include "base/tools/Object.h" + + namespace xmrig { @@ -35,7 +32,10 @@ class Timer; class ITimerListener { public: - virtual ~ITimerListener() = default; + XMRIG_DISABLE_COPY_MOVE(ITimerListener) + + ITimerListener() = default; + virtual ~ITimerListener() = default; virtual void onTimer(const Timer *timer) = 0; }; diff --git a/src/base/net/http/HttpClient.cpp b/src/base/net/http/HttpClient.cpp index ff82eab0..92ca6fac 100644 --- a/src/base/net/http/HttpClient.cpp +++ b/src/base/net/http/HttpClient.cpp @@ -95,7 +95,7 @@ void xmrig::HttpClient::handshake() { headers.insert({ "Host", host() }); headers.insert({ "Connection", "close" }); - headers.insert({ "User-Agent", Platform::userAgent() }); + headers.insert({ "User-Agent", Platform::userAgent().data() }); if (!body.empty()) { headers.insert({ "Content-Length", std::to_string(body.size()) }); diff --git a/src/base/tools/Arguments.cpp b/src/base/tools/Arguments.cpp index eebe0e73..b6bcec8d 100644 --- a/src/base/tools/Arguments.cpp +++ b/src/base/tools/Arguments.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-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 diff --git a/src/base/tools/Arguments.h b/src/base/tools/Arguments.h index e7a10536..a65c4459 100644 --- a/src/base/tools/Arguments.h +++ b/src/base/tools/Arguments.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-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 diff --git a/src/base/tools/Baton.h b/src/base/tools/Baton.h index 646dc0b8..accaf51c 100644 --- a/src/base/tools/Baton.h +++ b/src/base/tools/Baton.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 diff --git a/src/base/tools/Chrono.h b/src/base/tools/Chrono.h index e464f361..99ad19cf 100644 --- a/src/base/tools/Chrono.h +++ b/src/base/tools/Chrono.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 diff --git a/src/base/tools/Handle.h b/src/base/tools/Handle.h index 1a7d08f1..a25381d8 100644 --- a/src/base/tools/Handle.h +++ b/src/base/tools/Handle.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h index 7e460e44..412ae6ff 100644 --- a/src/base/tools/Object.h +++ b/src/base/tools/Object.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 diff --git a/src/base/tools/String.cpp b/src/base/tools/String.cpp index 8187f467..cfc8e040 100644 --- a/src/base/tools/String.cpp +++ b/src/base/tools/String.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-2019 SChernykh - * Copyright 2016-2019 XMRig , + * 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 @@ -30,6 +24,21 @@ #include +xmrig::String::String(const char *str, size_t size) : + m_size(size) +{ + if (str == nullptr) { + m_size = 0; + + return; + } + + m_data = new char[m_size + 1]; + memcpy(m_data, str, m_size); + m_data[m_size] = '\0'; +} + + xmrig::String::String(const char *str) : m_size(str == nullptr ? 0 : strlen(str)) { @@ -42,17 +51,18 @@ xmrig::String::String(const char *str) : } -xmrig::String::String(const char *str, size_t size) : - m_size(size) +xmrig::String::String(const rapidjson::Value &value) { - if (str == nullptr) { - m_size = 0; + if (!value.IsString()) { + return; + } + if ((m_size = value.GetStringLength()) == 0) { return; } m_data = new char[m_size + 1]; - memcpy(m_data, str, m_size); + memcpy(m_data, value.GetString(), m_size); m_data[m_size] = '\0'; } @@ -103,8 +113,10 @@ rapidjson::Value xmrig::String::toJSON(rapidjson::Document &doc) const std::vector xmrig::String::split(char sep) const { - std::vector out; + std::vector out; if (m_size == 0) { + out.emplace_back(*this); + return out; } diff --git a/src/base/tools/String.h b/src/base/tools/String.h index df649576..4ba603ce 100644 --- a/src/base/tools/String.h +++ b/src/base/tools/String.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-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 @@ -50,8 +44,9 @@ public: inline String(char *str) : m_data(str), m_size(str == nullptr ? 0 : strlen(str)) {} inline String(String &&other) noexcept : m_data(other.m_data), m_size(other.m_size) { other.m_data = nullptr; other.m_size = 0; } - String(const char *str); String(const char *str, size_t size); + String(const char *str); + String(const rapidjson::Value &value); String(const String &other); inline ~String() { delete [] m_data; } @@ -66,6 +61,7 @@ public: inline bool isEmpty() const { return size() == 0; } inline bool isNull() const { return m_data == nullptr; } + inline bool isValid() const { return m_data != nullptr; } inline char *data() { return m_data; } inline const char *data() const { return m_data; } inline size_t size() const { return m_size; } @@ -73,7 +69,7 @@ public: inline bool operator!=(const char *str) const { return !isEqual(str); } inline bool operator!=(const String &other) const { return !isEqual(other); } - inline bool operator<(const String &str) const { return strcmp(data(), str.data()) < 0; } + inline bool operator<(const String &str) const { return !isEmpty() && !str.isEmpty() && strcmp(data(), str.data()) < 0; } inline bool operator==(const char *str) const { return isEqual(str); } inline bool operator==(const String &other) const { return isEqual(other); } inline operator const char*() const { return m_data; } diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 8f38d59f..67a93488 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -163,7 +163,7 @@ public: reply.AddMember("version", APP_VERSION, allocator); reply.AddMember("kind", APP_KIND, allocator); - reply.AddMember("ua", StringRef(Platform::userAgent()), allocator); + reply.AddMember("ua", Platform::userAgent().toJSON(), allocator); reply.AddMember("cpu", Cpu::toJSON(doc), allocator); reply.AddMember("donate_level", controller->config()->pools().donateLevel(), allocator); reply.AddMember("paused", !enabled, allocator); From f16d1837f8f6cf5917acba1605e7598c20e8a65e Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 29 Nov 2020 14:05:50 +0100 Subject: [PATCH 4/6] Optimized JIT compiler More branch-free code --- src/crypto/randomx/jit_compiler_x86.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 182de1fa..9753701e 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -495,12 +495,10 @@ namespace randomx { emit32(instr.getImm32(), code, codePos); emitByte(0x25, code, codePos); - if (instr.getModCond() < StoreL3Condition) { - emit32(AddressMask[instr.getModMem()], code, codePos); - } - else { - emit32(ScratchpadL3Mask, code, codePos); - } + + const uint32_t mask1 = AddressMask[instr.getModMem()]; + const uint32_t mask2 = ScratchpadL3Mask; + emit32((instr.mod < (StoreL3Condition << 4)) ? mask1 : mask2, code, codePos); } FORCE_INLINE void JitCompilerX86::genAddressImm(const Instruction& instr, uint8_t* code, uint32_t& codePos) { From d557fe7f39a538dfa4e08ff3f1c05b0fe8005988 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 29 Nov 2020 22:02:48 +0100 Subject: [PATCH 5/6] Fix RandomX init when switching to other algo and back --- src/crypto/rx/Rx.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/rx/Rx.cpp b/src/crypto/rx/Rx.cpp index 01a00214..2fffb0e6 100644 --- a/src/crypto/rx/Rx.cpp +++ b/src/crypto/rx/Rx.cpp @@ -104,10 +104,6 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu randomx_set_scratchpad_prefetch_mode(config.scratchpadPrefetchMode()); randomx_set_huge_pages_jit(cpu.isHugePagesJit()); - if (isReady(seed)) { - return true; - } - if (!msrInitialized) { msrEnabled = msrInit(config, cpu.threads().get(seed.algorithm()).data()); msrInitialized = true; @@ -121,6 +117,10 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu osInitialized = true; } + if (isReady(seed)) { + return true; + } + d_ptr->queue.enqueue(seed, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), config.isOneGbPages(), config.mode(), cpu.priority()); return false; From 91979dc4dd78142f423de3e215ab1649f3070b8a Mon Sep 17 00:00:00 2001 From: xmrig Date: Tue, 1 Dec 2020 20:12:27 +0700 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fac62510..074e3997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v6.6.2 +- [#1958](https://github.com/xmrig/xmrig/pull/1958) Added example mining scripts to help new miners. +- [#1959](https://github.com/xmrig/xmrig/pull/1959) Optimized JIT compiler. +- [#1960](https://github.com/xmrig/xmrig/pull/1960) Fixed RandomX init when switching to other algo and back. + # v6.6.1 - Fixed, benchmark validation on NUMA hardware produced incorrect results in some conditions.