commit
f3b267b9e4
112 changed files with 7635 additions and 6426 deletions
28
CHANGELOG.md
28
CHANGELOG.md
|
@ -1,3 +1,31 @@
|
||||||
|
# v5.5.1
|
||||||
|
- [#1469](https://github.com/xmrig/xmrig/issues/1469) Fixed build with gcc 4.8.
|
||||||
|
- [#1473](https://github.com/xmrig/xmrig/pull/1473) Added RandomX auto-config for mobile Ryzen APUs.
|
||||||
|
- [#1477](https://github.com/xmrig/xmrig/pull/1477) Fixed build with Clang.
|
||||||
|
- [#1489](https://github.com/xmrig/xmrig/pull/1489) RandomX JIT compiler tweaks.
|
||||||
|
- [#1493](https://github.com/xmrig/xmrig/pull/1493) Default value for Intel MSR preset changed to `15`.
|
||||||
|
- Fixed unwanted resume after RandomX dataset change.
|
||||||
|
|
||||||
|
# v5.5.0
|
||||||
|
- [#179](https://github.com/xmrig/xmrig/issues/179) Added support for [environment variables](https://xmrig.com/docs/miner/environment-variables) in config file.
|
||||||
|
- [#1445](https://github.com/xmrig/xmrig/pull/1445) Removed `rx/v` algorithm.
|
||||||
|
- [#1453](https://github.com/xmrig/xmrig/issues/1453) Fixed crash on 32bit systems.
|
||||||
|
- [#1459](https://github.com/xmrig/xmrig/issues/1459) Fixed crash on very low memory systems.
|
||||||
|
- [#1465](https://github.com/xmrig/xmrig/pull/1465) Added fix for 1st-gen Ryzen crashes.
|
||||||
|
- [#1466](https://github.com/xmrig/xmrig/pull/1466) Added `cn-pico/tlo` algorithm.
|
||||||
|
- Added `--randomx-no-rdmsr` command line option.
|
||||||
|
- Added console title for Windows with miner name and version.
|
||||||
|
- On Windows `priority` option now also change base priority.
|
||||||
|
|
||||||
|
# v5.4.0
|
||||||
|
- [#1434](https://github.com/xmrig/xmrig/pull/1434) Added RandomSFX (`rx/sfx`) algorithm for Safex Cash.
|
||||||
|
- [#1445](https://github.com/xmrig/xmrig/pull/1445) Added RandomV (`rx/v`) algorithm for *new* MoneroV.
|
||||||
|
- [#1419](https://github.com/xmrig/xmrig/issues/1419) Added reverting MSR changes on miner exit, use `"rdmsr": false,` in `"randomx"` object to disable this feature.
|
||||||
|
- [#1423](https://github.com/xmrig/xmrig/issues/1423) Fixed conflicts with exists WinRing0 driver service.
|
||||||
|
- [#1425](https://github.com/xmrig/xmrig/issues/1425) Fixed crash on first generation Zen CPUs (MSR mod accidentally enable Opcache), additionally now you can disable Opcache and enable MSR mod via config `"wrmsr": ["0xc0011020:0x0", "0xc0011021:0x60", "0xc0011022:0x510000", "0xc001102b:0x1808cc16"],`.
|
||||||
|
- Added advanced usage for `wrmsr` option, for example: `"wrmsr": ["0x1a4:0x6"],` (Intel) and `"wrmsr": ["0xc0011020:0x0", "0xc0011021:0x40:0xffffffffffffffdf", "0xc0011022:0x510000", "0xc001102b:0x1808cc16"],` (Ryzen).
|
||||||
|
- Added new config option `"verbose"` and command line option `--verbose`.
|
||||||
|
|
||||||
# v5.3.0
|
# v5.3.0
|
||||||
- [#1414](https://github.com/xmrig/xmrig/pull/1414) Added native MSR support for Windows, by using signed **WinRing0 driver** (© 2007-2009 OpenLibSys.org).
|
- [#1414](https://github.com/xmrig/xmrig/pull/1414) Added native MSR support for Windows, by using signed **WinRing0 driver** (© 2007-2009 OpenLibSys.org).
|
||||||
- Added new [MSR documentation](https://xmrig.com/docs/miner/randomx-optimization-guide/msr).
|
- Added new [MSR documentation](https://xmrig.com/docs/miner/randomx-optimization-guide/msr).
|
||||||
|
|
|
@ -13,6 +13,8 @@ option(WITH_HTTP "Enable HTTP protocol support (client/server)" ON)
|
||||||
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
|
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
|
||||||
option(WITH_TLS "Enable OpenSSL support" ON)
|
option(WITH_TLS "Enable OpenSSL support" ON)
|
||||||
option(WITH_ASM "Enable ASM PoW implementations" ON)
|
option(WITH_ASM "Enable ASM PoW implementations" ON)
|
||||||
|
option(WITH_MSR "Enable MSR mod & 1st-gen Ryzen fix" ON)
|
||||||
|
option(WITH_ENV_VARS "Enable environment variables support in config file" ON)
|
||||||
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
||||||
option(WITH_OPENCL "Enable OpenCL backend" ON)
|
option(WITH_OPENCL "Enable OpenCL backend" ON)
|
||||||
option(WITH_CUDA "Enable CUDA backend" ON)
|
option(WITH_CUDA "Enable CUDA backend" ON)
|
||||||
|
|
10
README.md
10
README.md
|
@ -1,6 +1,6 @@
|
||||||
# XMRig
|
# XMRig
|
||||||
|
|
||||||
**:warning: [Monero will change PoW algorithm to RandomX on November 30.](https://github.com/xmrig/xmrig/issues/1204)**
|
**:warning: [Monero changed PoW algorithm to RandomX on November 30.](https://github.com/xmrig/xmrig/issues/1204)**
|
||||||
|
|
||||||
[](https://github.com/xmrig/xmrig/releases)
|
[](https://github.com/xmrig/xmrig/releases)
|
||||||
[](https://github.com/xmrig/xmrig/releases)
|
[](https://github.com/xmrig/xmrig/releases)
|
||||||
|
@ -38,7 +38,7 @@ Network:
|
||||||
-u, --user=USERNAME username for mining server
|
-u, --user=USERNAME username for mining server
|
||||||
-p, --pass=PASSWORD password for mining server
|
-p, --pass=PASSWORD password for mining server
|
||||||
-O, --userpass=U:P username:password pair for mining server
|
-O, --userpass=U:P username:password pair for mining server
|
||||||
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)
|
-k, --keepalive send keepalive packet for prevent timeout (needs pool support)
|
||||||
--nicehash enable nicehash.com support
|
--nicehash enable nicehash.com support
|
||||||
--rig-id=ID rig identifier for pool-side statistics (needs pool support)
|
--rig-id=ID rig identifier for pool-side statistics (needs pool support)
|
||||||
--tls enable SSL/TLS support (needs pool support)
|
--tls enable SSL/TLS support (needs pool support)
|
||||||
|
@ -62,11 +62,12 @@ CPU backend:
|
||||||
--cpu-no-yield prefer maximum hashrate rather than system response/stability
|
--cpu-no-yield prefer maximum hashrate rather than system response/stability
|
||||||
--no-huge-pages disable huge pages support
|
--no-huge-pages disable huge pages support
|
||||||
--asm=ASM ASM optimizations, possible values: auto, none, intel, ryzen, bulldozer
|
--asm=ASM ASM optimizations, possible values: auto, none, intel, ryzen, bulldozer
|
||||||
--randomx-init=N threads count to initialize RandomX dataset
|
--randomx-init=N thread count to initialize RandomX dataset
|
||||||
--randomx-no-numa disable NUMA support for RandomX
|
--randomx-no-numa disable NUMA support for RandomX
|
||||||
--randomx-mode=MODE RandomX mode: auto, fast, light
|
--randomx-mode=MODE RandomX mode: auto, fast, light
|
||||||
--randomx-1gb-pages use 1GB hugepages for dataset (Linux only)
|
--randomx-1gb-pages use 1GB hugepages for dataset (Linux only)
|
||||||
--randomx-wrmsr=N write value (0-15) to Intel MSR register 0x1a4 or do nothing (-1) (Linux only)
|
--randomx-wrmsr=N write custom value (0-15) to Intel MSR register 0x1a4 or disable MSR mod (-1)
|
||||||
|
--randomx-no-rdmsr disable reverting initial MSR values on exit
|
||||||
|
|
||||||
API:
|
API:
|
||||||
--api-worker-id=ID custom worker-id for API
|
--api-worker-id=ID custom worker-id for API
|
||||||
|
@ -98,6 +99,7 @@ Logging:
|
||||||
--print-time=N print hashrate report every N seconds
|
--print-time=N print hashrate report every N seconds
|
||||||
--health-print-time=N print health report every N seconds
|
--health-print-time=N print health report every N seconds
|
||||||
--no-color disable colored output
|
--no-color disable colored output
|
||||||
|
--verbose verbose output
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
-c, --config=FILE load a JSON-format configuration file
|
-c, --config=FILE load a JSON-format configuration file
|
||||||
|
|
|
@ -79,11 +79,24 @@ if (WITH_RANDOMX)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WITH_MSR AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND (XMRIG_OS_WIN OR XMRIG_OS_LINUX))
|
||||||
list(APPEND SOURCES_CRYPTO src/crypto/rx/Rx_windows.cpp)
|
add_definitions(/DXMRIG_FEATURE_MSR)
|
||||||
elseif (XMRIG_OS_LINUX AND NOT XMRIG_ARM)
|
add_definitions(/DXMRIG_FIX_RYZEN)
|
||||||
|
message("-- WITH_MSR=ON")
|
||||||
|
|
||||||
|
if (XMRIG_OS_WIN)
|
||||||
|
list(APPEND SOURCES_CRYPTO src/crypto/rx/Rx_win.cpp)
|
||||||
|
elseif (XMRIG_OS_LINUX)
|
||||||
list(APPEND SOURCES_CRYPTO src/crypto/rx/Rx_linux.cpp)
|
list(APPEND SOURCES_CRYPTO src/crypto/rx/Rx_linux.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
list(APPEND HEADERS_CRYPTO src/crypto/rx/msr/MsrItem.h)
|
||||||
|
list(APPEND SOURCES_CRYPTO src/crypto/rx/msr/MsrItem.cpp)
|
||||||
|
else()
|
||||||
|
remove_definitions(/DXMRIG_FEATURE_MSR)
|
||||||
|
remove_definitions(/DXMRIG_FIX_RYZEN)
|
||||||
|
message("-- WITH_MSR=OFF")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
remove_definitions(/DXMRIG_ALGO_RANDOMX)
|
remove_definitions(/DXMRIG_ALGO_RANDOMX)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -12,6 +12,8 @@ Option `coin` useful for pools without algorithm negotiation support or daemon t
|
||||||
|
|
||||||
| Name | Memory | Version | Notes |
|
| Name | Memory | Version | Notes |
|
||||||
|------|--------|---------|-------|
|
|------|--------|---------|-------|
|
||||||
|
| `rx/sfx` | 2 MB | 5.4.0+ | RandomSFX (RandomX variant for Safex). |
|
||||||
|
| `rx/v` | 2 MB | 5.4.0+ | RandomV (RandomX variant for new MoneroV). |
|
||||||
| `rx/arq` | 256 KB | 4.3.0+ | RandomARQ (RandomX variant for ArQmA). |
|
| `rx/arq` | 256 KB | 4.3.0+ | RandomARQ (RandomX variant for ArQmA). |
|
||||||
| `rx/0` | 2 MB | 3.2.0+ | RandomX (Monero). |
|
| `rx/0` | 2 MB | 3.2.0+ | RandomX (Monero). |
|
||||||
| `argon2/chukwa` | 512 KB | 3.1.0+ | Argon2id (Chukwa). |
|
| `argon2/chukwa` | 512 KB | 3.1.0+ | Argon2id (Chukwa). |
|
||||||
|
@ -23,7 +25,6 @@ Option `coin` useful for pools without algorithm negotiation support or daemon t
|
||||||
| `cn/zls` | 2 MB | 2.14.0+ | CryptoNight variant 2 with 3/4 iterations. |
|
| `cn/zls` | 2 MB | 2.14.0+ | CryptoNight variant 2 with 3/4 iterations. |
|
||||||
| `cn/double` | 2 MB | 2.14.0+ | CryptoNight variant 2 with double iterations. |
|
| `cn/double` | 2 MB | 2.14.0+ | CryptoNight variant 2 with double iterations. |
|
||||||
| `cn/r` | 2 MB | 2.13.0+ | CryptoNightR (Monero's variant 4). |
|
| `cn/r` | 2 MB | 2.13.0+ | CryptoNightR (Monero's variant 4). |
|
||||||
| `cn/wow` | 2 MB | 2.12.0+ | CryptoNightR (Wownero). |
|
|
||||||
| `cn/gpu` | 2 MB | 2.11.0+ | CryptoNight-GPU. |
|
| `cn/gpu` | 2 MB | 2.11.0+ | CryptoNight-GPU. |
|
||||||
| `cn-pico` | 256 KB | 2.10.0+ | CryptoNight-Pico. |
|
| `cn-pico` | 256 KB | 2.10.0+ | CryptoNight-Pico. |
|
||||||
| `cn/half` | 2 MB | 2.9.0+ | CryptoNight variant 2 with half iterations. |
|
| `cn/half` | 2 MB | 2.9.0+ | CryptoNight variant 2 with half iterations. |
|
||||||
|
|
|
@ -13,7 +13,7 @@ if cat /proc/cpuinfo | grep "AMD Ryzen" > /dev/null;
|
||||||
elif cat /proc/cpuinfo | grep "Intel" > /dev/null;
|
elif cat /proc/cpuinfo | grep "Intel" > /dev/null;
|
||||||
then
|
then
|
||||||
echo "Detected Intel"
|
echo "Detected Intel"
|
||||||
wrmsr -a 0x1a4 6
|
wrmsr -a 0x1a4 0xf
|
||||||
echo "MSR register values for Intel applied"
|
echo "MSR register values for Intel applied"
|
||||||
else
|
else
|
||||||
echo "No supported CPU detected"
|
echo "No supported CPU detected"
|
||||||
|
|
|
@ -159,7 +159,7 @@ static void print_threads(Config *config)
|
||||||
|
|
||||||
static void print_commands(Config *)
|
static void print_commands(Config *)
|
||||||
{
|
{
|
||||||
if (Log::colors) {
|
if (Log::isColors()) {
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG(WHITE_BOLD_S "h") WHITE_BOLD("ashrate, ")
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG(WHITE_BOLD_S "h") WHITE_BOLD("ashrate, ")
|
||||||
MAGENTA_BG(WHITE_BOLD_S "p") WHITE_BOLD("ause, ")
|
MAGENTA_BG(WHITE_BOLD_S "p") WHITE_BOLD("ause, ")
|
||||||
MAGENTA_BG(WHITE_BOLD_S "r") WHITE_BOLD("esume"));
|
MAGENTA_BG(WHITE_BOLD_S "r") WHITE_BOLD("esume"));
|
||||||
|
|
|
@ -45,6 +45,7 @@ class IRxStorage
|
||||||
public:
|
public:
|
||||||
virtual ~IRxStorage() = default;
|
virtual ~IRxStorage() = default;
|
||||||
|
|
||||||
|
virtual bool isAllocated() const = 0;
|
||||||
virtual HugePagesInfo hugePages() const = 0;
|
virtual HugePagesInfo hugePages() const = 0;
|
||||||
virtual RxDataset *dataset(const Job &job, uint32_t nodeId) const = 0;
|
virtual RxDataset *dataset(const Job &job, uint32_t nodeId) const = 0;
|
||||||
virtual void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) = 0;
|
virtual void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) = 0;
|
||||||
|
|
|
@ -154,7 +154,8 @@ bool xmrig::CpuWorker<N>::selfTest()
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
if (m_algorithm.family() == Algorithm::CN_PICO) {
|
if (m_algorithm.family() == Algorithm::CN_PICO) {
|
||||||
return verify(Algorithm::CN_PICO_0, test_output_pico_trtl);
|
return verify(Algorithm::CN_PICO_0, test_output_pico_trtl) &&
|
||||||
|
verify(Algorithm::CN_PICO_TLO, test_output_pico_tlo);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,20 @@ namespace xmrig {
|
||||||
class ICpuInfo
|
class ICpuInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Vendor {
|
enum Vendor : uint32_t {
|
||||||
VENDOR_UNKNOWN,
|
VENDOR_UNKNOWN,
|
||||||
VENDOR_INTEL,
|
VENDOR_INTEL,
|
||||||
VENDOR_AMD
|
VENDOR_AMD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MsrMod : uint32_t {
|
||||||
|
MSR_MOD_NONE,
|
||||||
|
MSR_MOD_RYZEN,
|
||||||
|
MSR_MOD_INTEL,
|
||||||
|
MSR_MOD_CUSTOM,
|
||||||
|
MSR_MOD_MAX
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~ICpuInfo() = default;
|
virtual ~ICpuInfo() = default;
|
||||||
|
|
||||||
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
|
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
|
||||||
|
@ -58,6 +66,7 @@ public:
|
||||||
virtual const char *backend() const = 0;
|
virtual const char *backend() const = 0;
|
||||||
virtual const char *brand() const = 0;
|
virtual const char *brand() const = 0;
|
||||||
virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0;
|
virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0;
|
||||||
|
virtual MsrMod msrMod() const = 0;
|
||||||
virtual size_t cores() const = 0;
|
virtual size_t cores() const = 0;
|
||||||
virtual size_t L2() const = 0;
|
virtual size_t L2() const = 0;
|
||||||
virtual size_t L3() const = 0;
|
virtual size_t L3() const = 0;
|
||||||
|
|
|
@ -139,7 +139,13 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||||
m_aes = true;
|
m_aes = true;
|
||||||
|
|
||||||
if (m_vendor == VENDOR_AMD) {
|
if (m_vendor == VENDOR_AMD) {
|
||||||
m_assembly = (data.ext_family >= 23) ? Assembly::RYZEN : Assembly::BULLDOZER;
|
if (data.ext_family >= 23) {
|
||||||
|
m_assembly = Assembly::RYZEN;
|
||||||
|
m_msrMod = MSR_MOD_RYZEN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_assembly = Assembly::BULLDOZER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (m_vendor == VENDOR_INTEL) {
|
else if (m_vendor == VENDOR_INTEL) {
|
||||||
m_assembly = Assembly::INTEL;
|
m_assembly = Assembly::INTEL;
|
||||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
inline bool hasOneGbPages() const override { return m_pdpe1gb; }
|
inline bool hasOneGbPages() const override { return m_pdpe1gb; }
|
||||||
inline const char *backend() const override { return m_backend; }
|
inline const char *backend() const override { return m_backend; }
|
||||||
inline const char *brand() const override { return m_brand; }
|
inline const char *brand() const override { return m_brand; }
|
||||||
|
inline MsrMod msrMod() const override { return m_msrMod; }
|
||||||
inline size_t cores() const override { return m_cores; }
|
inline size_t cores() const override { return m_cores; }
|
||||||
inline size_t L2() const override { return m_L2; }
|
inline size_t L2() const override { return m_L2; }
|
||||||
inline size_t L3() const override { return m_L3; }
|
inline size_t L3() const override { return m_L3; }
|
||||||
|
@ -62,6 +63,7 @@ private:
|
||||||
char m_backend[32]{};
|
char m_backend[32]{};
|
||||||
char m_brand[64 + 5]{};
|
char m_brand[64 + 5]{};
|
||||||
const bool m_pdpe1gb = false;
|
const bool m_pdpe1gb = false;
|
||||||
|
MsrMod m_msrMod = MSR_MOD_NONE;
|
||||||
size_t m_cores = 0;
|
size_t m_cores = 0;
|
||||||
size_t m_L2 = 0;
|
size_t m_L2 = 0;
|
||||||
size_t m_L3 = 0;
|
size_t m_L3 = 0;
|
||||||
|
|
|
@ -175,11 +175,18 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
cpuid(PROCESSOR_INFO, data);
|
cpuid(PROCESSOR_INFO, data);
|
||||||
const int32_t family = get_masked(data[EAX_Reg], 12, 8) + get_masked(data[EAX_Reg], 28, 20);
|
const int32_t family = get_masked(data[EAX_Reg], 12, 8) + get_masked(data[EAX_Reg], 28, 20);
|
||||||
|
|
||||||
m_assembly = family >= 23 ? Assembly::RYZEN : Assembly::BULLDOZER;
|
if (family >= 23) {
|
||||||
|
m_assembly = Assembly::RYZEN;
|
||||||
|
m_msrMod = MSR_MOD_RYZEN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_assembly = Assembly::BULLDOZER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (memcmp(vendor, "GenuineIntel", 12) == 0) {
|
else if (memcmp(vendor, "GenuineIntel", 12) == 0) {
|
||||||
m_vendor = VENDOR_INTEL;
|
m_vendor = VENDOR_INTEL;
|
||||||
m_assembly = Assembly::INTEL;
|
m_assembly = Assembly::INTEL;
|
||||||
|
m_msrMod = MSR_MOD_INTEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -46,6 +46,7 @@ protected:
|
||||||
inline bool hasAVX2() const override { return m_avx2; }
|
inline bool hasAVX2() const override { return m_avx2; }
|
||||||
inline bool hasOneGbPages() const override { return m_pdpe1gb; }
|
inline bool hasOneGbPages() const override { return m_pdpe1gb; }
|
||||||
inline const char *brand() const override { return m_brand; }
|
inline const char *brand() const override { return m_brand; }
|
||||||
|
inline MsrMod msrMod() const override { return m_msrMod; }
|
||||||
inline size_t cores() const override { return 0; }
|
inline size_t cores() const override { return 0; }
|
||||||
inline size_t L2() const override { return 0; }
|
inline size_t L2() const override { return 0; }
|
||||||
inline size_t L3() const override { return 0; }
|
inline size_t L3() const override { return 0; }
|
||||||
|
@ -63,6 +64,7 @@ private:
|
||||||
bool m_aes = false;
|
bool m_aes = false;
|
||||||
const bool m_avx2 = false;
|
const bool m_avx2 = false;
|
||||||
const bool m_pdpe1gb = false;
|
const bool m_pdpe1gb = false;
|
||||||
|
MsrMod m_msrMod = MSR_MOD_NONE;
|
||||||
Vendor m_vendor = VENDOR_UNKNOWN;
|
Vendor m_vendor = VENDOR_UNKNOWN;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,15 @@ xmrig::CudaWorker::CudaWorker(size_t id, const CudaLaunchData &data) :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_runner || !m_runner->init()) {
|
if (!m_runner) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_runner->init()) {
|
||||||
|
delete m_runner;
|
||||||
|
|
||||||
|
m_runner = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ xmrig::CudaBaseRunner::~CudaBaseRunner()
|
||||||
bool xmrig::CudaBaseRunner::init()
|
bool xmrig::CudaBaseRunner::init()
|
||||||
{
|
{
|
||||||
m_ctx = CudaLib::alloc(m_data.thread.index(), m_data.thread.bfactor(), m_data.thread.bsleep());
|
m_ctx = CudaLib::alloc(m_data.thread.index(), m_data.thread.bfactor(), m_data.thread.bsleep());
|
||||||
if (CudaLib::deviceInfo(m_ctx, m_data.thread.blocks(), m_data.thread.threads(), m_data.algorithm, m_data.thread.datasetHost()) != 0) {
|
if (!callWrapper(CudaLib::deviceInfo(m_ctx, m_data.thread.blocks(), m_data.thread.threads(), m_data.algorithm, m_data.thread.datasetHost()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
#include "crypto/rx/RxDataset.h"
|
#include "crypto/rx/RxDataset.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::CudaRxRunner::CudaRxRunner(size_t index, const CudaLaunchData &data) : CudaBaseRunner(index, data),
|
xmrig::CudaRxRunner::CudaRxRunner(size_t index, const CudaLaunchData &data) :
|
||||||
|
CudaBaseRunner(index, data),
|
||||||
m_datasetHost(data.thread.datasetHost() > 0)
|
m_datasetHost(data.thread.datasetHost() > 0)
|
||||||
{
|
{
|
||||||
m_intensity = m_data.thread.threads() * m_data.thread.blocks();
|
m_intensity = m_data.thread.threads() * m_data.thread.blocks();
|
||||||
|
|
|
@ -41,7 +41,7 @@ xmrig::CudaDevice::CudaDevice(uint32_t index, int32_t bfactor, int32_t bsleep) :
|
||||||
m_index(index)
|
m_index(index)
|
||||||
{
|
{
|
||||||
auto ctx = CudaLib::alloc(index, bfactor, bsleep);
|
auto ctx = CudaLib::alloc(index, bfactor, bsleep);
|
||||||
if (CudaLib::deviceInfo(ctx, 0, 0, Algorithm::INVALID) != 0) {
|
if (!CudaLib::deviceInfo(ctx, 0, 0, Algorithm::INVALID)) {
|
||||||
CudaLib::release(ctx);
|
CudaLib::release(ctx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -107,7 +107,7 @@ uint32_t xmrig::CudaDevice::smx() const
|
||||||
|
|
||||||
void xmrig::CudaDevice::generate(const Algorithm &algorithm, CudaThreads &threads) const
|
void xmrig::CudaDevice::generate(const Algorithm &algorithm, CudaThreads &threads) const
|
||||||
{
|
{
|
||||||
if (CudaLib::deviceInfo(m_ctx, -1, -1, algorithm) != 0) {
|
if (!CudaLib::deviceInfo(m_ctx, -1, -1, algorithm)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
|
|
||||||
#include "backend/cuda/wrappers/CudaLib.h"
|
#include "backend/cuda/wrappers/CudaLib.h"
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
|
#include "crypto/rx/RxAlgo.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -48,6 +50,7 @@ static const char *kAlloc = "alloc";
|
||||||
static const char *kCnHash = "cnHash";
|
static const char *kCnHash = "cnHash";
|
||||||
static const char *kDeviceCount = "deviceCount";
|
static const char *kDeviceCount = "deviceCount";
|
||||||
static const char *kDeviceInfo = "deviceInfo";
|
static const char *kDeviceInfo = "deviceInfo";
|
||||||
|
static const char *kDeviceInfo_v2 = "deviceInfo_v2";
|
||||||
static const char *kDeviceInit = "deviceInit";
|
static const char *kDeviceInit = "deviceInit";
|
||||||
static const char *kDeviceInt = "deviceInt";
|
static const char *kDeviceInt = "deviceInt";
|
||||||
static const char *kDeviceName = "deviceName";
|
static const char *kDeviceName = "deviceName";
|
||||||
|
@ -60,6 +63,7 @@ static const char *kRelease = "release";
|
||||||
static const char *kRxHash = "rxHash";
|
static const char *kRxHash = "rxHash";
|
||||||
static const char *kRxPrepare = "rxPrepare";
|
static const char *kRxPrepare = "rxPrepare";
|
||||||
static const char *kSetJob = "setJob";
|
static const char *kSetJob = "setJob";
|
||||||
|
static const char *kSetJob_v2 = "setJob_v2";
|
||||||
static const char *kSymbolNotFound = "symbol not found";
|
static const char *kSymbolNotFound = "symbol not found";
|
||||||
static const char *kVersion = "version";
|
static const char *kVersion = "version";
|
||||||
|
|
||||||
|
@ -68,6 +72,7 @@ using alloc_t = nvid_ctx * (*)(uint32_
|
||||||
using cnHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint64_t, uint32_t *, uint32_t *);
|
using cnHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint64_t, uint32_t *, uint32_t *);
|
||||||
using deviceCount_t = uint32_t (*)();
|
using deviceCount_t = uint32_t (*)();
|
||||||
using deviceInfo_t = int32_t (*)(nvid_ctx *, int32_t, int32_t, int32_t, int32_t);
|
using deviceInfo_t = int32_t (*)(nvid_ctx *, int32_t, int32_t, int32_t, int32_t);
|
||||||
|
using deviceInfo_v2_t = bool (*)(nvid_ctx *, int32_t, int32_t, const char *, int32_t);
|
||||||
using deviceInit_t = bool (*)(nvid_ctx *);
|
using deviceInit_t = bool (*)(nvid_ctx *);
|
||||||
using deviceInt_t = int32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
using deviceInt_t = int32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||||
using deviceName_t = const char * (*)(nvid_ctx *);
|
using deviceName_t = const char * (*)(nvid_ctx *);
|
||||||
|
@ -80,6 +85,7 @@ using release_t = void (*)(nvid_ctx *);
|
||||||
using rxHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *);
|
using rxHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *);
|
||||||
using rxPrepare_t = bool (*)(nvid_ctx *, const void *, size_t, bool, uint32_t);
|
using rxPrepare_t = bool (*)(nvid_ctx *, const void *, size_t, bool, uint32_t);
|
||||||
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t);
|
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t);
|
||||||
|
using setJob_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const char *);
|
||||||
using version_t = uint32_t (*)(Version);
|
using version_t = uint32_t (*)(Version);
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,6 +93,7 @@ static alloc_t pAlloc = nullptr;
|
||||||
static cnHash_t pCnHash = nullptr;
|
static cnHash_t pCnHash = nullptr;
|
||||||
static deviceCount_t pDeviceCount = nullptr;
|
static deviceCount_t pDeviceCount = nullptr;
|
||||||
static deviceInfo_t pDeviceInfo = nullptr;
|
static deviceInfo_t pDeviceInfo = nullptr;
|
||||||
|
static deviceInfo_v2_t pDeviceInfo_v2 = nullptr;
|
||||||
static deviceInit_t pDeviceInit = nullptr;
|
static deviceInit_t pDeviceInit = nullptr;
|
||||||
static deviceInt_t pDeviceInt = nullptr;
|
static deviceInt_t pDeviceInt = nullptr;
|
||||||
static deviceName_t pDeviceName = nullptr;
|
static deviceName_t pDeviceName = nullptr;
|
||||||
|
@ -99,6 +106,7 @@ static release_t pRelease = nullptr;
|
||||||
static rxHash_t pRxHash = nullptr;
|
static rxHash_t pRxHash = nullptr;
|
||||||
static rxPrepare_t pRxPrepare = nullptr;
|
static rxPrepare_t pRxPrepare = nullptr;
|
||||||
static setJob_t pSetJob = nullptr;
|
static setJob_t pSetJob = nullptr;
|
||||||
|
static setJob_v2_t pSetJob_v2 = nullptr;
|
||||||
static version_t pVersion = nullptr;
|
static version_t pVersion = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +124,7 @@ String CudaLib::m_loader;
|
||||||
bool xmrig::CudaLib::init(const char *fileName)
|
bool xmrig::CudaLib::init(const char *fileName)
|
||||||
{
|
{
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
m_loader = fileName == nullptr ? defaultLoader() : fileName;
|
m_loader = fileName == nullptr ? defaultLoader() : Env::expand(fileName);
|
||||||
m_ready = uv_dlopen(m_loader, &cudaLib) == 0 && load();
|
m_ready = uv_dlopen(m_loader, &cudaLib) == 0 && load();
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -143,6 +151,18 @@ bool xmrig::CudaLib::cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::CudaLib::deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm, int32_t dataset_host) noexcept
|
||||||
|
{
|
||||||
|
const Algorithm algo = RxAlgo::id(algorithm);
|
||||||
|
|
||||||
|
if (pDeviceInfo_v2) {
|
||||||
|
return pDeviceInfo_v2(ctx, blocks, threads, algo.isValid() ? algo.shortName() : nullptr, dataset_host);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pDeviceInfo(ctx, blocks, threads, algo, dataset_host) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::CudaLib::deviceInit(nvid_ctx *ctx) noexcept
|
bool xmrig::CudaLib::deviceInit(nvid_ctx *ctx) noexcept
|
||||||
{
|
{
|
||||||
return pDeviceInit(ctx);
|
return pDeviceInit(ctx);
|
||||||
|
@ -163,7 +183,12 @@ bool xmrig::CudaLib::rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datase
|
||||||
|
|
||||||
bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept
|
bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept
|
||||||
{
|
{
|
||||||
return pSetJob(ctx, data, size, algorithm);
|
const Algorithm algo = RxAlgo::id(algorithm);
|
||||||
|
if (pSetJob_v2) {
|
||||||
|
return pSetJob_v2(ctx, data, size, algo.shortName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return pSetJob(ctx, data, size, algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,12 +210,6 @@ const char *xmrig::CudaLib::pluginVersion() noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int xmrig::CudaLib::deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm, int32_t dataset_host) noexcept
|
|
||||||
{
|
|
||||||
return pDeviceInfo(ctx, blocks, threads, algorithm, dataset_host);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t xmrig::CudaLib::deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept
|
int32_t xmrig::CudaLib::deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept
|
||||||
{
|
{
|
||||||
return pDeviceInt(ctx, property);
|
return pDeviceInt(ctx, property);
|
||||||
|
@ -290,11 +309,13 @@ bool xmrig::CudaLib::load()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uv_dlsym(&cudaLib, kDeviceInfo_v2, reinterpret_cast<void**>(&pDeviceInfo_v2));
|
||||||
|
uv_dlsym(&cudaLib, kSetJob_v2, reinterpret_cast<void**>(&pSetJob_v2));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DLSYM(Alloc);
|
DLSYM(Alloc);
|
||||||
DLSYM(CnHash);
|
DLSYM(CnHash);
|
||||||
DLSYM(DeviceCount);
|
DLSYM(DeviceCount);
|
||||||
DLSYM(DeviceInfo);
|
|
||||||
DLSYM(DeviceInit);
|
DLSYM(DeviceInit);
|
||||||
DLSYM(DeviceInt);
|
DLSYM(DeviceInt);
|
||||||
DLSYM(DeviceName);
|
DLSYM(DeviceName);
|
||||||
|
@ -306,8 +327,15 @@ bool xmrig::CudaLib::load()
|
||||||
DLSYM(Release);
|
DLSYM(Release);
|
||||||
DLSYM(RxHash);
|
DLSYM(RxHash);
|
||||||
DLSYM(RxPrepare);
|
DLSYM(RxPrepare);
|
||||||
DLSYM(SetJob);
|
|
||||||
DLSYM(Version);
|
DLSYM(Version);
|
||||||
|
|
||||||
|
if (!pDeviceInfo_v2) {
|
||||||
|
DLSYM(DeviceInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pSetJob_v2) {
|
||||||
|
DLSYM(SetJob);
|
||||||
|
}
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +346,7 @@ bool xmrig::CudaLib::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *xmrig::CudaLib::defaultLoader()
|
xmrig::String xmrig::CudaLib::defaultLoader()
|
||||||
{
|
{
|
||||||
# if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
return "/System/Library/Frameworks/OpenCL.framework/OpenCL"; // FIXME
|
return "/System/Library/Frameworks/OpenCL.framework/OpenCL"; // FIXME
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
static inline const String &loader() { return m_loader; }
|
static inline const String &loader() { return m_loader; }
|
||||||
|
|
||||||
static bool cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height, uint64_t target, uint32_t *rescount, uint32_t *resnonce);
|
static bool cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height, uint64_t target, uint32_t *rescount, uint32_t *resnonce);
|
||||||
|
static bool deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm, int32_t dataset_host = -1) noexcept;
|
||||||
static bool deviceInit(nvid_ctx *ctx) noexcept;
|
static bool deviceInit(nvid_ctx *ctx) noexcept;
|
||||||
static bool rxHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept;
|
static bool rxHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept;
|
||||||
static bool rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datasetSize, bool dataset_host, uint32_t batchSize) noexcept;
|
static bool rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datasetSize, bool dataset_host, uint32_t batchSize) noexcept;
|
||||||
|
@ -81,7 +82,6 @@ public:
|
||||||
static const char *deviceName(nvid_ctx *ctx) noexcept;
|
static const char *deviceName(nvid_ctx *ctx) noexcept;
|
||||||
static const char *lastError(nvid_ctx *ctx) noexcept;
|
static const char *lastError(nvid_ctx *ctx) noexcept;
|
||||||
static const char *pluginVersion() noexcept;
|
static const char *pluginVersion() noexcept;
|
||||||
static int deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm, int32_t dataset_host = -1) noexcept;
|
|
||||||
static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept;
|
static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept;
|
||||||
static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept;
|
static nvid_ctx *alloc(uint32_t id, int32_t bfactor, int32_t bsleep) noexcept;
|
||||||
static std::string version(uint32_t version);
|
static std::string version(uint32_t version);
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool load();
|
static bool load();
|
||||||
static const char *defaultLoader();
|
static String defaultLoader();
|
||||||
|
|
||||||
static bool m_initialized;
|
static bool m_initialized;
|
||||||
static bool m_ready;
|
static bool m_ready;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include "backend/opencl/OclLaunchData.h"
|
#include "backend/opencl/OclLaunchData.h"
|
||||||
|
|
||||||
#include "backend/common/Tags.h"
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/OclConfig.h"
|
#include "backend/opencl/OclConfig.h"
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
#define ALGO_CN_HEAVY_TUBE 15
|
#define ALGO_CN_HEAVY_TUBE 15
|
||||||
#define ALGO_CN_HEAVY_XHV 16
|
#define ALGO_CN_HEAVY_XHV 16
|
||||||
#define ALGO_CN_PICO_0 17
|
#define ALGO_CN_PICO_0 17
|
||||||
#define ALGO_RX_0 18
|
#define ALGO_CN_PICO_TLO 18
|
||||||
#define ALGO_RX_WOW 19
|
#define ALGO_RX_0 19
|
||||||
#define ALGO_RX_LOKI 20
|
#define ALGO_RX_WOW 20
|
||||||
#define ALGO_RX_ARQMA 21
|
#define ALGO_RX_LOKI 21
|
||||||
#define ALGO_AR2_CHUKWA 22
|
#define ALGO_RX_ARQMA 22
|
||||||
#define ALGO_AR2_WRKZ 23
|
#define ALGO_RX_SFX 23
|
||||||
|
#define ALGO_AR2_CHUKWA 24
|
||||||
|
#define ALGO_AR2_WRKZ 25
|
||||||
|
|
||||||
#define FAMILY_UNKNOWN 0
|
#define FAMILY_UNKNOWN 0
|
||||||
#define FAMILY_CN 1
|
#define FAMILY_CN 1
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -40,6 +40,12 @@ bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorith
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mobile Ryzen APUs
|
||||||
|
if (device.type() == OclDevice::Raven) {
|
||||||
|
threads.add(OclThread(device.index(), (device.computeUnits() > 4) ? 256 : 128, 8, 1, true, true, 6));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const size_t mem = device.globalMemSize();
|
const size_t mem = device.globalMemSize();
|
||||||
auto config = RxAlgo::base(algorithm);
|
auto config = RxAlgo::base(algorithm);
|
||||||
bool gcnAsm = false;
|
bool gcnAsm = false;
|
||||||
|
|
|
@ -52,11 +52,11 @@ xmrig::OclRxBaseRunner::OclRxBaseRunner(size_t index, const OclLaunchData &data)
|
||||||
m_worksize = 8;
|
m_worksize = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.device.type() == OclDevice::Vega_10 || data.device.type() == OclDevice::Vega_20) {
|
if (data.device.type() == OclDevice::Vega_10 || data.device.type() == OclDevice::Vega_20 || data.device.type() == OclDevice::Raven) {
|
||||||
m_gcn_version = 14;
|
m_gcn_version = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_options += " -DALGO=" + std::to_string(m_algorithm.id());
|
m_options += " -DALGO=" + std::to_string(RxAlgo::id(m_algorithm));
|
||||||
m_options += " -DWORKERS_PER_HASH=" + std::to_string(m_worksize);
|
m_options += " -DWORKERS_PER_HASH=" + std::to_string(m_worksize);
|
||||||
m_options += " -DGCN_VERSION=" + std::to_string(m_gcn_version);
|
m_options += " -DGCN_VERSION=" + std::to_string(m_gcn_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,12 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/wrappers/OclLib.h"
|
||||||
#include "backend/common/Tags.h"
|
#include "backend/common/Tags.h"
|
||||||
#include "backend/opencl/wrappers/OclError.h"
|
#include "backend/opencl/wrappers/OclError.h"
|
||||||
#include "backend/opencl/wrappers/OclLib.h"
|
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(OCL_DEBUG_REFERENCE_COUNT)
|
#if defined(OCL_DEBUG_REFERENCE_COUNT)
|
||||||
# define LOG_REFS(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
# define LOG_REFS(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
||||||
|
@ -188,7 +190,7 @@ static String getOclString(FUNC fn, OBJ obj, PARAM param)
|
||||||
bool xmrig::OclLib::init(const char *fileName)
|
bool xmrig::OclLib::init(const char *fileName)
|
||||||
{
|
{
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
m_loader = fileName == nullptr ? defaultLoader() : fileName;
|
m_loader = fileName == nullptr ? defaultLoader() : Env::expand(fileName);
|
||||||
m_ready = uv_dlopen(m_loader, &oclLib) == 0 && load();
|
m_ready = uv_dlopen(m_loader, &oclLib) == 0 && load();
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +259,7 @@ bool xmrig::OclLib::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *xmrig::OclLib::defaultLoader()
|
xmrig::String xmrig::OclLib::defaultLoader()
|
||||||
{
|
{
|
||||||
# if defined(__APPLE__)
|
# if defined(__APPLE__)
|
||||||
return "/System/Library/Frameworks/OpenCL.framework/OpenCL";
|
return "/System/Library/Frameworks/OpenCL.framework/OpenCL";
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool load();
|
static bool load();
|
||||||
static const char *defaultLoader();
|
static String defaultLoader();
|
||||||
|
|
||||||
static bool m_initialized;
|
static bool m_initialized;
|
||||||
static bool m_ready;
|
static bool m_ready;
|
||||||
|
|
|
@ -26,17 +26,13 @@
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "base/api/Api.h"
|
#include "base/api/Api.h"
|
||||||
#include "3rdparty/http-parser/http_parser.h"
|
#include "3rdparty/http-parser/http_parser.h"
|
||||||
#include "base/api/interfaces/IApiListener.h"
|
#include "base/api/interfaces/IApiListener.h"
|
||||||
#include "base/api/requests/HttpApiRequest.h"
|
#include "base/api/requests/HttpApiRequest.h"
|
||||||
#include "base/io/json/Json.h"
|
#include "base/io/json/Json.h"
|
||||||
#include "base/kernel/Base.h"
|
#include "base/kernel/Base.h"
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
#include "base/tools/Buffer.h"
|
#include "base/tools/Buffer.h"
|
||||||
#include "base/tools/Chrono.h"
|
#include "base/tools/Chrono.h"
|
||||||
#include "core/config/Config.h"
|
#include "core/config/Config.h"
|
||||||
|
@ -158,7 +154,7 @@ void xmrig::Api::exec(IApiRequest &request)
|
||||||
|
|
||||||
auto &reply = request.reply();
|
auto &reply = request.reply();
|
||||||
reply.AddMember("id", StringRef(m_id), allocator);
|
reply.AddMember("id", StringRef(m_id), allocator);
|
||||||
reply.AddMember("worker_id", StringRef(m_workerId), allocator);
|
reply.AddMember("worker_id", m_workerId.toJSON(), allocator);
|
||||||
reply.AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
reply.AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
||||||
reply.AddMember("restricted", request.isRestricted(), allocator);
|
reply.AddMember("restricted", request.isRestricted(), allocator);
|
||||||
reply.AddMember("resources", getResources(request.doc()), allocator);
|
reply.AddMember("resources", getResources(request.doc()), allocator);
|
||||||
|
@ -245,12 +241,8 @@ void xmrig::Api::genId(const String &id)
|
||||||
|
|
||||||
void xmrig::Api::genWorkerId(const String &id)
|
void xmrig::Api::genWorkerId(const String &id)
|
||||||
{
|
{
|
||||||
memset(m_workerId, 0, sizeof(m_workerId));
|
m_workerId = Env::expand(id);
|
||||||
|
if (m_workerId.isEmpty()) {
|
||||||
if (id.size() > 0) {
|
m_workerId = Env::hostname();
|
||||||
strncpy(m_workerId, id.data(), sizeof(m_workerId) - 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gethostname(m_workerId, sizeof(m_workerId) - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IBaseListener.h"
|
#include "base/kernel/interfaces/IBaseListener.h"
|
||||||
#include "base/tools/Object.h"
|
#include "base/tools/Object.h"
|
||||||
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -71,7 +72,7 @@ private:
|
||||||
|
|
||||||
Base *m_base;
|
Base *m_base;
|
||||||
char m_id[32]{};
|
char m_id[32]{};
|
||||||
char m_workerId[128]{};
|
String m_workerId;
|
||||||
const uint64_t m_timestamp;
|
const uint64_t m_timestamp;
|
||||||
Httpd *m_httpd = nullptr;
|
Httpd *m_httpd = nullptr;
|
||||||
std::vector<IApiListener *> m_listeners;
|
std::vector<IApiListener *> m_listeners;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -84,6 +84,8 @@ public:
|
||||||
virtual RequestType type() const = 0;
|
virtual RequestType type() const = 0;
|
||||||
virtual Source source() const = 0;
|
virtual Source source() const = 0;
|
||||||
virtual void done(int status) = 0;
|
virtual void done(int status) = 0;
|
||||||
|
virtual void setRpcError(int code, const char *message = nullptr) = 0;
|
||||||
|
virtual void setRpcResult(rapidjson::Value &result) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -53,6 +53,10 @@ static inline const char *rpcError(int code) {
|
||||||
return "Invalid params";
|
return "Invalid params";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code >= HTTP_STATUS_BAD_REQUEST && code <= HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED) {
|
||||||
|
return http_status_str(static_cast<http_status>(code));
|
||||||
|
}
|
||||||
|
|
||||||
return "Internal error";
|
return "Internal error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ xmrig::HttpApiRequest::HttpApiRequest(const HttpData &req, bool restricted) :
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_rpcMethod = Json::getString(json(), "method");
|
m_rpcMethod = Json::getString(m_body, "method");
|
||||||
if (m_rpcMethod.isEmpty()) {
|
if (m_rpcMethod.isEmpty()) {
|
||||||
done(RPC_INVALID_REQUEST);
|
done(RPC_INVALID_REQUEST);
|
||||||
|
|
||||||
|
@ -129,6 +133,10 @@ bool xmrig::HttpApiRequest::accept()
|
||||||
|
|
||||||
const rapidjson::Value &xmrig::HttpApiRequest::json() const
|
const rapidjson::Value &xmrig::HttpApiRequest::json() const
|
||||||
{
|
{
|
||||||
|
if (type() == REQ_JSON_RPC) {
|
||||||
|
return Json::getValue(m_body, "params");
|
||||||
|
}
|
||||||
|
|
||||||
return m_body;
|
return m_body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,25 +158,14 @@ void xmrig::HttpApiRequest::done(int status)
|
||||||
m_res.setStatus(HTTP_STATUS_OK);
|
m_res.setStatus(HTTP_STATUS_OK);
|
||||||
|
|
||||||
if (status != HTTP_STATUS_OK) {
|
if (status != HTTP_STATUS_OK) {
|
||||||
if (status == HTTP_STATUS_NOT_FOUND) {
|
setRpcError(status == HTTP_STATUS_NOT_FOUND ? RPC_METHOD_NOT_FOUND : status);
|
||||||
status = RPC_METHOD_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value error(kObjectType);
|
|
||||||
error.AddMember("code", status, allocator);
|
|
||||||
error.AddMember("message", StringRef(rpcError(status)), allocator);
|
|
||||||
|
|
||||||
reply().AddMember(StringRef(kError), error, allocator);
|
|
||||||
}
|
}
|
||||||
else if (!reply().HasMember(kResult)) {
|
else if (!reply().HasMember(kResult)) {
|
||||||
Value result(kObjectType);
|
Value result(kObjectType);
|
||||||
result.AddMember("status", "OK", allocator);
|
result.AddMember("status", "OK", allocator);
|
||||||
|
|
||||||
reply().AddMember(StringRef(kResult), result, allocator);
|
setRpcResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply().AddMember("jsonrpc", "2.0", allocator);
|
|
||||||
reply().AddMember(StringRef(kId), Value().CopyFrom(Json::getValue(json(), kId), allocator), allocator);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_res.setStatus(status);
|
m_res.setStatus(status);
|
||||||
|
@ -176,3 +173,38 @@ void xmrig::HttpApiRequest::done(int status)
|
||||||
|
|
||||||
m_res.end();
|
m_res.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::HttpApiRequest::setRpcError(int code, const char *message)
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc().GetAllocator();
|
||||||
|
|
||||||
|
Value error(kObjectType);
|
||||||
|
error.AddMember("code", code, allocator);
|
||||||
|
error.AddMember("message", message ? StringRef(message) : StringRef(rpcError(code)), allocator);
|
||||||
|
|
||||||
|
rpcDone(kError, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::HttpApiRequest::setRpcResult(rapidjson::Value &result)
|
||||||
|
{
|
||||||
|
rpcDone(kResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::HttpApiRequest::rpcDone(const char *key, rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
ApiRequest::done(0);
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc().GetAllocator();
|
||||||
|
|
||||||
|
reply().AddMember(StringRef(key), value, allocator);
|
||||||
|
reply().AddMember("jsonrpc", "2.0", allocator);
|
||||||
|
reply().AddMember(StringRef(kId), Value().CopyFrom(Json::getValue(m_body, kId), allocator), allocator);
|
||||||
|
|
||||||
|
m_res.setStatus(HTTP_STATUS_OK);
|
||||||
|
m_res.end();
|
||||||
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -53,8 +53,12 @@ protected:
|
||||||
const rapidjson::Value &json() const override;
|
const rapidjson::Value &json() const override;
|
||||||
Method method() const override;
|
Method method() const override;
|
||||||
void done(int status) override;
|
void done(int status) override;
|
||||||
|
void setRpcError(int code, const char *message = nullptr) override;
|
||||||
|
void setRpcResult(rapidjson::Value &result) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void rpcDone(const char *key, rapidjson::Value &value);
|
||||||
|
|
||||||
const HttpData &m_req;
|
const HttpData &m_req;
|
||||||
HttpApiResponse m_res;
|
HttpApiResponse m_res;
|
||||||
int m_parsed = 0;
|
int m_parsed = 0;
|
||||||
|
|
|
@ -12,6 +12,7 @@ set(HEADERS_BASE
|
||||||
src/base/kernel/config/BaseConfig.h
|
src/base/kernel/config/BaseConfig.h
|
||||||
src/base/kernel/config/BaseTransform.h
|
src/base/kernel/config/BaseTransform.h
|
||||||
src/base/kernel/Entry.h
|
src/base/kernel/Entry.h
|
||||||
|
src/base/kernel/Env.h
|
||||||
src/base/kernel/interfaces/IBaseListener.h
|
src/base/kernel/interfaces/IBaseListener.h
|
||||||
src/base/kernel/interfaces/IClient.h
|
src/base/kernel/interfaces/IClient.h
|
||||||
src/base/kernel/interfaces/IClientListener.h
|
src/base/kernel/interfaces/IClientListener.h
|
||||||
|
@ -66,6 +67,7 @@ set(SOURCES_BASE
|
||||||
src/base/kernel/config/BaseConfig.cpp
|
src/base/kernel/config/BaseConfig.cpp
|
||||||
src/base/kernel/config/BaseTransform.cpp
|
src/base/kernel/config/BaseTransform.cpp
|
||||||
src/base/kernel/Entry.cpp
|
src/base/kernel/Entry.cpp
|
||||||
|
src/base/kernel/Env.cpp
|
||||||
src/base/kernel/Platform.cpp
|
src/base/kernel/Platform.cpp
|
||||||
src/base/kernel/Process.cpp
|
src/base/kernel/Process.cpp
|
||||||
src/base/kernel/Signals.cpp
|
src/base/kernel/Signals.cpp
|
||||||
|
@ -167,3 +169,15 @@ else()
|
||||||
remove_definitions(/DXMRIG_FEATURE_HTTP)
|
remove_definitions(/DXMRIG_FEATURE_HTTP)
|
||||||
remove_definitions(/DXMRIG_FEATURE_API)
|
remove_definitions(/DXMRIG_FEATURE_API)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (WITH_ENV_VARS AND CMAKE_CXX_COMPILER_ID MATCHES GNU AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
|
||||||
|
set(WITH_ENV_VARS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (WITH_ENV_VARS)
|
||||||
|
add_definitions(/DXMRIG_FEATURE_ENV)
|
||||||
|
else()
|
||||||
|
remove_definitions(/DXMRIG_FEATURE_ENV)
|
||||||
|
endif()
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -40,7 +40,9 @@ static const rapidjson::Value kNullValue;
|
||||||
|
|
||||||
bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool defaultValue)
|
bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsBool()) {
|
if (i != obj.MemberEnd() && i->value.IsBool()) {
|
||||||
|
@ -51,9 +53,17 @@ bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool def
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Json::isEmpty(const rapidjson::Value &obj)
|
||||||
|
{
|
||||||
|
return !obj.IsObject() || obj.ObjectEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
|
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsString()) {
|
if (i != obj.MemberEnd() && i->value.IsString()) {
|
||||||
|
@ -66,7 +76,9 @@ const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key,
|
||||||
|
|
||||||
const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const char *key)
|
const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const char *key)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return kNullValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsArray()) {
|
if (i != obj.MemberEnd() && i->value.IsArray()) {
|
||||||
|
@ -79,7 +91,9 @@ const rapidjson::Value &xmrig::Json::getArray(const rapidjson::Value &obj, const
|
||||||
|
|
||||||
const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, const char *key)
|
const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, const char *key)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return kNullValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsObject()) {
|
if (i != obj.MemberEnd() && i->value.IsObject()) {
|
||||||
|
@ -92,7 +106,9 @@ const rapidjson::Value &xmrig::Json::getObject(const rapidjson::Value &obj, cons
|
||||||
|
|
||||||
const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const char *key)
|
const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const char *key)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return kNullValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd()) {
|
if (i != obj.MemberEnd()) {
|
||||||
|
@ -105,7 +121,9 @@ const rapidjson::Value &xmrig::Json::getValue(const rapidjson::Value &obj, const
|
||||||
|
|
||||||
int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
|
int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsInt()) {
|
if (i != obj.MemberEnd() && i->value.IsInt()) {
|
||||||
|
@ -118,7 +136,9 @@ int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaul
|
||||||
|
|
||||||
int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue)
|
int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsInt64()) {
|
if (i != obj.MemberEnd() && i->value.IsInt64()) {
|
||||||
|
@ -131,7 +151,9 @@ int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int6
|
||||||
|
|
||||||
uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
|
uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsUint64()) {
|
if (i != obj.MemberEnd() && i->value.IsUint64()) {
|
||||||
|
@ -144,7 +166,9 @@ uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, ui
|
||||||
|
|
||||||
unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue)
|
unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue)
|
||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
if (isEmpty(obj)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
auto i = obj.FindMember(key);
|
auto i = obj.FindMember(key);
|
||||||
if (i != obj.MemberEnd() && i->value.IsUint()) {
|
if (i != obj.MemberEnd() && i->value.IsUint()) {
|
||||||
|
@ -169,5 +193,5 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
|
||||||
|
|
||||||
bool xmrig::JsonReader::isEmpty() const
|
bool xmrig::JsonReader::isEmpty() const
|
||||||
{
|
{
|
||||||
return !m_obj.IsObject() || m_obj.ObjectEmpty();
|
return Json::isEmpty(m_obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -37,6 +37,7 @@ class Json
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool getBool(const rapidjson::Value &obj, const char *key, bool defaultValue = false);
|
static bool getBool(const rapidjson::Value &obj, const char *key, bool defaultValue = false);
|
||||||
|
static bool isEmpty(const rapidjson::Value &obj);
|
||||||
static const char *getString(const rapidjson::Value &obj, const char *key, const char *defaultValue = nullptr);
|
static const char *getString(const rapidjson::Value &obj, const char *key, const char *defaultValue = nullptr);
|
||||||
static const rapidjson::Value &getArray(const rapidjson::Value &obj, const char *key);
|
static const rapidjson::Value &getArray(const rapidjson::Value &obj, const char *key);
|
||||||
static const rapidjson::Value &getObject(const rapidjson::Value &obj, const char *key);
|
static const rapidjson::Value &getObject(const rapidjson::Value &obj, const char *key);
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (Log::background && m_backends.empty()) {
|
if (Log::isBackground() && m_backends.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,9 +195,10 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool Log::background = false;
|
bool Log::m_background = false;
|
||||||
bool Log::colors = true;
|
bool Log::m_colors = true;
|
||||||
LogPrivate *Log::d = new LogPrivate();
|
LogPrivate *Log::d = new LogPrivate();
|
||||||
|
uint32_t Log::m_verbose = 0;
|
||||||
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#define XMRIG_LOG_H
|
#define XMRIG_LOG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +57,19 @@ public:
|
||||||
static void print(const char *fmt, ...);
|
static void print(const char *fmt, ...);
|
||||||
static void print(Level level, const char *fmt, ...);
|
static void print(Level level, const char *fmt, ...);
|
||||||
|
|
||||||
static bool background;
|
static inline bool isBackground() { return m_background; }
|
||||||
static bool colors;
|
static inline bool isColors() { return m_colors; }
|
||||||
|
static inline bool isVerbose() { return m_verbose > 0; }
|
||||||
|
static inline uint32_t verbose() { return m_verbose; }
|
||||||
|
static inline void setBackground(bool background) { m_background = background; }
|
||||||
|
static inline void setColors(bool colors) { m_colors = colors; }
|
||||||
|
static inline void setVerbose(uint32_t verbose) { m_verbose = verbose; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool m_background;
|
||||||
|
static bool m_colors;
|
||||||
|
static uint32_t m_verbose;
|
||||||
|
|
||||||
static LogPrivate *d;
|
static LogPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,6 +138,7 @@ private:
|
||||||
#define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
#define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
||||||
#define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__)
|
#define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__)
|
||||||
#define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__)
|
#define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__)
|
||||||
|
#define LOG_VERBOSE(x, ...) if (xmrig::Log::isVerbose()) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
||||||
|
|
||||||
#ifdef APP_DEBUG
|
#ifdef APP_DEBUG
|
||||||
# define LOG_DEBUG(x, ...) xmrig::Log::print(xmrig::Log::DEBUG, x, ##__VA_ARGS__)
|
# define LOG_DEBUG(x, ...) xmrig::Log::print(xmrig::Log::DEBUG, x, ##__VA_ARGS__)
|
||||||
|
|
|
@ -27,28 +27,29 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
#include "base/tools/Handle.h"
|
|
||||||
#include "base/io/log/backends/ConsoleLog.h"
|
#include "base/io/log/backends/ConsoleLog.h"
|
||||||
|
#include "base/tools/Handle.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::ConsoleLog::ConsoleLog()
|
xmrig::ConsoleLog::ConsoleLog()
|
||||||
{
|
{
|
||||||
if (!isSupported()) {
|
if (!isSupported()) {
|
||||||
Log::colors = false;
|
Log::setColors(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tty = new uv_tty_t;
|
m_tty = new uv_tty_t;
|
||||||
|
|
||||||
if (uv_tty_init(uv_default_loop(), m_tty, 1, 0) < 0) {
|
if (uv_tty_init(uv_default_loop(), m_tty, 1, 0) < 0) {
|
||||||
Log::colors = false;
|
Log::setColors(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_tty_set_mode(m_tty, UV_TTY_MODE_NORMAL);
|
uv_tty_set_mode(m_tty, UV_TTY_MODE_NORMAL);
|
||||||
|
|
||||||
# ifdef WIN32
|
# ifdef XMRIG_OS_WIN
|
||||||
m_stream = reinterpret_cast<uv_stream_t*>(m_tty);
|
m_stream = reinterpret_cast<uv_stream_t*>(m_tty);
|
||||||
|
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
@ -59,6 +60,8 @@ xmrig::ConsoleLog::ConsoleLog()
|
||||||
SetConsoleMode(handle, mode | ENABLE_EXTENDED_FLAGS);
|
SetConsoleMode(handle, mode | ENABLE_EXTENDED_FLAGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetConsoleTitleA(APP_NAME " " APP_VERSION);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +74,11 @@ xmrig::ConsoleLog::~ConsoleLog()
|
||||||
|
|
||||||
void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors)
|
void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors)
|
||||||
{
|
{
|
||||||
if (!m_tty || Log::colors != colors) {
|
if (!m_tty || Log::isColors() != colors) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef _WIN32
|
# ifdef XMRIG_OS_WIN
|
||||||
uv_buf_t buf = uv_buf_init(const_cast<char *>(line), static_cast<unsigned int>(size));
|
uv_buf_t buf = uv_buf_init(const_cast<char *>(line), static_cast<unsigned int>(size));
|
||||||
|
|
||||||
if (!isWritable()) {
|
if (!isWritable()) {
|
||||||
|
@ -99,7 +102,7 @@ bool xmrig::ConsoleLog::isSupported() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef XMRIG_OS_WIN
|
||||||
bool xmrig::ConsoleLog::isWritable() const
|
bool xmrig::ConsoleLog::isWritable() const
|
||||||
{
|
{
|
||||||
if (!m_stream || uv_is_writable(m_stream) != 1) {
|
if (!m_stream || uv_is_writable(m_stream) != 1) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ private:
|
||||||
|
|
||||||
uv_tty_t *m_tty = nullptr;
|
uv_tty_t *m_tty = nullptr;
|
||||||
|
|
||||||
# ifdef _WIN32
|
# ifdef XMRIG_OS_WIN
|
||||||
bool isWritable() const;
|
bool isWritable() const;
|
||||||
|
|
||||||
uv_stream_t *m_stream = nullptr;
|
uv_stream_t *m_stream = nullptr;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "base/io/log/backends/FileLog.h"
|
#include "base/io/log/backends/FileLog.h"
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
xmrig::FileLog::FileLog(const char *fileName)
|
xmrig::FileLog::FileLog(const char *fileName)
|
||||||
{
|
{
|
||||||
uv_fs_t req;
|
uv_fs_t req;
|
||||||
m_file = uv_fs_open(uv_default_loop(), &req, fileName, O_CREAT | O_APPEND | O_WRONLY, 0644, nullptr);
|
m_file = uv_fs_open(uv_default_loop(), &req, Env::expand(fileName), O_CREAT | O_APPEND | O_WRONLY, 0644, nullptr);
|
||||||
uv_fs_req_cleanup(&req);
|
uv_fs_req_cleanup(&req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ private:
|
||||||
return config.release();
|
return config.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.addFile(process->location(Process::ExeLocation, "config.json"));
|
chain.addFile(Process::location(Process::ExeLocation, "config.json"));
|
||||||
|
|
||||||
if (read(chain, config)) {
|
if (read(chain, config)) {
|
||||||
return config.release();
|
return config.release();
|
||||||
|
@ -177,7 +177,7 @@ int xmrig::Base::init()
|
||||||
Platform::init(config()->userAgent());
|
Platform::init(config()->userAgent());
|
||||||
|
|
||||||
if (isBackground()) {
|
if (isBackground()) {
|
||||||
Log::background = true;
|
Log::setBackground(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log::add(new ConsoleLog());
|
Log::add(new ConsoleLog());
|
||||||
|
|
|
@ -101,9 +101,9 @@ static int showVersion()
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HWLOC
|
#ifdef XMRIG_FEATURE_HWLOC
|
||||||
static int exportTopology(const Process &process)
|
static int exportTopology(const Process &)
|
||||||
{
|
{
|
||||||
const String path = process.location(Process::ExeLocation, "topology.xml");
|
const String path = Process::location(Process::ExeLocation, "topology.xml");
|
||||||
|
|
||||||
hwloc_topology_t topology;
|
hwloc_topology_t topology;
|
||||||
hwloc_topology_init(&topology);
|
hwloc_topology_init(&topology);
|
||||||
|
|
147
src/base/kernel/Env.cpp
Normal file
147
src/base/kernel/Env.cpp
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
|
#include "base/kernel/Process.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
#include <uv.h>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef UV_MAXHOSTNAMESIZE
|
||||||
|
# ifdef MAXHOSTNAMELEN
|
||||||
|
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
|
||||||
|
# else
|
||||||
|
# define UV_MAXHOSTNAMESIZE 256
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_ENV
|
||||||
|
static std::map<String, String> variables;
|
||||||
|
|
||||||
|
|
||||||
|
static void createVariables()
|
||||||
|
{
|
||||||
|
variables.insert({ "XMRIG_VERSION", APP_VERSION });
|
||||||
|
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation, "") });
|
||||||
|
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation, "") });
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::String xmrig::Env::expand(const char *in)
|
||||||
|
{
|
||||||
|
# ifdef XMRIG_FEATURE_ENV
|
||||||
|
if (in == nullptr) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string text(in);
|
||||||
|
if (text.size() < 4) {
|
||||||
|
return text.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const std::regex env_re{R"--(\$\{([^}]+)\})--"};
|
||||||
|
|
||||||
|
std::map<std::string, String> vars;
|
||||||
|
|
||||||
|
for (std::sregex_iterator i = std::sregex_iterator(text.begin(), text.end(), env_re); i != std::sregex_iterator(); ++i) {
|
||||||
|
std::smatch m = *i;
|
||||||
|
const auto var = m.str();
|
||||||
|
|
||||||
|
if (vars.count(var)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vars.insert({ var, get(m[1].str().c_str()) });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &kv : vars) {
|
||||||
|
if (kv.second.isNull()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = text.find(kv.first, pos)) != std::string::npos) {
|
||||||
|
text.replace(pos, kv.first.size(), kv.second);
|
||||||
|
pos += kv.second.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.c_str();
|
||||||
|
# else
|
||||||
|
return in;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::String xmrig::Env::get(const String &name)
|
||||||
|
{
|
||||||
|
# ifdef XMRIG_FEATURE_ENV
|
||||||
|
if (variables.empty()) {
|
||||||
|
createVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variables.count(name)) {
|
||||||
|
return variables.at(name);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return static_cast<const char *>(getenv(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::String xmrig::Env::hostname()
|
||||||
|
{
|
||||||
|
char buf[UV_MAXHOSTNAMESIZE]{};
|
||||||
|
size_t size = sizeof(buf);
|
||||||
|
|
||||||
|
# if UV_VERSION_HEX >= 0x010c00
|
||||||
|
if (uv_os_gethostname(buf, &size) == 0) {
|
||||||
|
return static_cast<const char *>(buf);
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
if (gethostname(buf, size) == 0) {
|
||||||
|
return static_cast<const char *>(buf);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
47
src/base/kernel/Env.h
Normal file
47
src/base/kernel/Env.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_ENV_H
|
||||||
|
#define XMRIG_ENV_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Env
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static String expand(const char *in);
|
||||||
|
static String get(const String &name);
|
||||||
|
static String hostname();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_ENV_H */
|
|
@ -51,6 +51,7 @@ public:
|
||||||
static uint32_t setTimerResolution(uint32_t resolution);
|
static uint32_t setTimerResolution(uint32_t resolution);
|
||||||
static void init(const char *userAgent);
|
static void init(const char *userAgent);
|
||||||
static void restoreTimerResolution();
|
static void restoreTimerResolution();
|
||||||
|
static void setProcessPriority(int priority);
|
||||||
static void setThreadPriority(int priority);
|
static void setThreadPriority(int priority);
|
||||||
|
|
||||||
static inline const char *userAgent() { return m_userAgent; }
|
static inline const char *userAgent() { return m_userAgent; }
|
||||||
|
|
|
@ -83,6 +83,11 @@ void xmrig::Platform::restoreTimerResolution()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Platform::setProcessPriority(int)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Platform::setThreadPriority(int priority)
|
void xmrig::Platform::setThreadPriority(int priority)
|
||||||
{
|
{
|
||||||
if (priority == -1) {
|
if (priority == -1) {
|
||||||
|
|
|
@ -111,6 +111,11 @@ void xmrig::Platform::restoreTimerResolution()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Platform::setProcessPriority(int)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Platform::setThreadPriority(int priority)
|
void xmrig::Platform::setThreadPriority(int priority)
|
||||||
{
|
{
|
||||||
if (priority == -1) {
|
if (priority == -1) {
|
||||||
|
|
|
@ -131,6 +131,43 @@ void xmrig::Platform::restoreTimerResolution()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Platform::setProcessPriority(int priority)
|
||||||
|
{
|
||||||
|
if (priority == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD prio = IDLE_PRIORITY_CLASS;
|
||||||
|
switch (priority)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
prio = BELOW_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
prio = NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
prio = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
prio = HIGH_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
prio = REALTIME_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPriorityClass(GetCurrentProcess(), prio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Platform::setThreadPriority(int priority)
|
void xmrig::Platform::setThreadPriority(int priority)
|
||||||
{
|
{
|
||||||
if (priority == -1) {
|
if (priority == -1) {
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
#include "base/tools/Chrono.h"
|
#include "base/tools/Chrono.h"
|
||||||
|
|
||||||
|
|
||||||
static size_t location(xmrig::Process::Location location, char *buf, size_t max)
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
static size_t getLocation(Process::Location location, char *buf, size_t max)
|
||||||
{
|
{
|
||||||
using namespace xmrig;
|
using namespace xmrig;
|
||||||
|
|
||||||
|
@ -48,6 +51,9 @@ static size_t location(xmrig::Process::Location location, char *buf, size_t max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
xmrig::Process::Process(int argc, char **argv) :
|
xmrig::Process::Process(int argc, char **argv) :
|
||||||
m_arguments(argc, argv)
|
m_arguments(argc, argv)
|
||||||
{
|
{
|
||||||
|
@ -55,12 +61,12 @@ xmrig::Process::Process(int argc, char **argv) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::String xmrig::Process::location(Location location, const char *fileName) const
|
xmrig::String xmrig::Process::location(Location location, const char *fileName)
|
||||||
{
|
{
|
||||||
constexpr const size_t max = 520;
|
constexpr const size_t max = 520;
|
||||||
|
|
||||||
char *buf = new char[max]();
|
char *buf = new char[max]();
|
||||||
size_t size = ::location(location, buf, max);
|
size_t size = getLocation(location, buf, max);
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
Process(int argc, char **argv);
|
Process(int argc, char **argv);
|
||||||
|
|
||||||
String location(Location location, const char *fileName = nullptr) const;
|
static String location(Location location, const char *fileName = nullptr);
|
||||||
|
|
||||||
inline const Arguments &arguments() const { return m_arguments; }
|
inline const Arguments &arguments() const { return m_arguments; }
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,10 +23,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include "base/kernel/config/BaseConfig.h"
|
||||||
#include <stdio.h>
|
#include "base/io/json/Json.h"
|
||||||
#include <stdlib.h>
|
#include "base/io/log/Log.h"
|
||||||
#include <string.h>
|
#include "base/kernel/interfaces/IJsonReader.h"
|
||||||
|
#include "rapidjson/document.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,79 +46,27 @@
|
||||||
# include "backend/cpu/Cpu.h"
|
# include "backend/cpu/Cpu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XMRIG_AMD_PROJECT
|
|
||||||
# if defined(__APPLE__)
|
namespace xmrig {
|
||||||
# include <OpenCL/cl.h>
|
|
||||||
# else
|
|
||||||
# include "3rdparty/CL/cl.h"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_NVIDIA_PROJECT
|
const char *BaseConfig::kApi = "api";
|
||||||
# include "nvidia/cryptonight.h"
|
const char *BaseConfig::kApiId = "id";
|
||||||
#endif
|
const char *BaseConfig::kApiWorkerId = "worker-id";
|
||||||
|
const char *BaseConfig::kAutosave = "autosave";
|
||||||
|
const char *BaseConfig::kBackground = "background";
|
||||||
|
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::kPrintTime = "print-time";
|
||||||
|
const char *BaseConfig::kSyslog = "syslog";
|
||||||
|
const char *BaseConfig::kUserAgent = "user-agent";
|
||||||
|
const char *BaseConfig::kVerbose = "verbose";
|
||||||
|
const char *BaseConfig::kWatch = "watch";
|
||||||
|
|
||||||
|
|
||||||
#include "base/io/json/Json.h"
|
} // namespace xmrig
|
||||||
#include "base/io/log/Log.h"
|
|
||||||
#include "base/kernel/config/BaseConfig.h"
|
|
||||||
#include "base/kernel/interfaces/IJsonReader.h"
|
|
||||||
#include "donate.h"
|
|
||||||
#include "rapidjson/document.h"
|
|
||||||
#include "rapidjson/filewritestream.h"
|
|
||||||
#include "rapidjson/prettywriter.h"
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
|
|
||||||
void xmrig::BaseConfig::printVersions()
|
|
||||||
{
|
|
||||||
char buf[256] = { 0 };
|
|
||||||
|
|
||||||
# if defined(__clang__)
|
|
||||||
snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
|
||||||
# elif defined(__GNUC__)
|
|
||||||
snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
|
||||||
# elif defined(_MSC_VER)
|
|
||||||
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
|
|
||||||
|
|
||||||
# if defined(XMRIG_AMD_PROJECT)
|
|
||||||
# if CL_VERSION_2_0
|
|
||||||
const char *ocl = "2.0";
|
|
||||||
# elif CL_VERSION_1_2
|
|
||||||
const char *ocl = "1.2";
|
|
||||||
# elif CL_VERSION_1_1
|
|
||||||
const char *ocl = "1.1";
|
|
||||||
# elif CL_VERSION_1_0
|
|
||||||
const char *ocl = "1.0";
|
|
||||||
# else
|
|
||||||
const char *ocl = "0.0";
|
|
||||||
# endif
|
|
||||||
int length = snprintf(buf, sizeof buf, "OpenCL/%s ", ocl);
|
|
||||||
# elif defined(XMRIG_NVIDIA_PROJECT)
|
|
||||||
const int cudaVersion = cuda_get_runtime_version();
|
|
||||||
int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
std::string libs;
|
|
||||||
|
|
||||||
# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT)
|
|
||||||
{
|
|
||||||
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
|
||||||
snprintf(buf, sizeof buf, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
|
|
||||||
libs += buf;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(XMRIG_FEATURE_HWLOC)
|
|
||||||
libs += Cpu::info()->backend();
|
|
||||||
# endif
|
|
||||||
|
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s"), "LIBS", uv_version_string(), libs.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||||
|
@ -121,25 +77,25 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_autoSave = reader.getBool("autosave", m_autoSave);
|
m_autoSave = reader.getBool(kAutosave, m_autoSave);
|
||||||
m_background = reader.getBool("background", m_background);
|
m_background = reader.getBool(kBackground, m_background);
|
||||||
m_dryRun = reader.getBool("dry-run", m_dryRun);
|
m_dryRun = reader.getBool(kDryRun, m_dryRun);
|
||||||
m_syslog = reader.getBool("syslog", m_syslog);
|
m_syslog = reader.getBool(kSyslog, m_syslog);
|
||||||
m_watch = reader.getBool("watch", m_watch);
|
m_watch = reader.getBool(kWatch, m_watch);
|
||||||
Log::colors = reader.getBool("colors", Log::colors);
|
m_logFile = reader.getString(kLogFile);
|
||||||
m_logFile = reader.getString("log-file");
|
m_userAgent = reader.getString(kUserAgent);
|
||||||
m_userAgent = reader.getString("user-agent");
|
|
||||||
m_version = reader.getUint("version");
|
|
||||||
|
|
||||||
setPrintTime(reader.getUint("print-time", 60));
|
Log::setColors(reader.getBool(kColors, Log::isColors()));
|
||||||
|
setPrintTime(reader.getUint(kPrintTime, 60));
|
||||||
|
setVerbose(reader.getValue(kVerbose));
|
||||||
|
|
||||||
const rapidjson::Value &api = reader.getObject("api");
|
const rapidjson::Value &api = reader.getObject(kApi);
|
||||||
if (api.IsObject()) {
|
if (api.IsObject()) {
|
||||||
m_apiId = Json::getString(api, "id");
|
m_apiId = Json::getString(api, kApiId);
|
||||||
m_apiWorkerId = Json::getString(api, "worker-id");
|
m_apiWorkerId = Json::getString(api, kApiWorkerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_http.load(reader.getObject("http"));
|
m_http.load(reader.getObject(kHttp));
|
||||||
m_pools.load(reader);
|
m_pools.load(reader);
|
||||||
|
|
||||||
return m_pools.active() > 0;
|
return m_pools.active() > 0;
|
||||||
|
@ -162,3 +118,46 @@ bool xmrig::BaseConfig::save()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BaseConfig::printVersions()
|
||||||
|
{
|
||||||
|
char buf[256] = { 0 };
|
||||||
|
|
||||||
|
# if defined(__clang__)
|
||||||
|
snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
|
||||||
|
|
||||||
|
std::string libs;
|
||||||
|
|
||||||
|
# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||||
|
{
|
||||||
|
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||||
|
snprintf(buf, sizeof buf, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
|
||||||
|
libs += buf;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(XMRIG_FEATURE_HWLOC)
|
||||||
|
libs += Cpu::info()->backend();
|
||||||
|
# endif
|
||||||
|
|
||||||
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s"), "LIBS", uv_version_string(), libs.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BaseConfig::setVerbose(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (value.IsBool()) {
|
||||||
|
Log::setVerbose(value.GetBool() ? 1 : 0);
|
||||||
|
}
|
||||||
|
else if (value.IsUint()) {
|
||||||
|
Log::setVerbose(value.GetUint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -40,6 +40,21 @@ class IJsonReader;
|
||||||
class BaseConfig : public IConfig
|
class BaseConfig : public IConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const char *kApi;
|
||||||
|
static const char *kApiId;
|
||||||
|
static const char *kApiWorkerId;
|
||||||
|
static const char *kAutosave;
|
||||||
|
static const char *kBackground;
|
||||||
|
static const char *kColors;
|
||||||
|
static const char *kDryRun;
|
||||||
|
static const char *kHttp;
|
||||||
|
static const char *kLogFile;
|
||||||
|
static const char *kPrintTime;
|
||||||
|
static const char *kSyslog;
|
||||||
|
static const char *kUserAgent;
|
||||||
|
static const char *kVerbose;
|
||||||
|
static const char *kWatch;
|
||||||
|
|
||||||
BaseConfig() = default;
|
BaseConfig() = default;
|
||||||
|
|
||||||
inline bool isAutoSave() const { return m_autoSave; }
|
inline bool isAutoSave() const { return m_autoSave; }
|
||||||
|
@ -78,10 +93,11 @@ protected:
|
||||||
String m_logFile;
|
String m_logFile;
|
||||||
String m_userAgent;
|
String m_userAgent;
|
||||||
uint32_t m_printTime = 60;
|
uint32_t m_printTime = 60;
|
||||||
uint32_t m_version = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||||
|
|
||||||
|
void setVerbose(const rapidjson::Value &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,27 +33,17 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/kernel/config/BaseTransform.h"
|
||||||
#include "base/io/json/JsonChain.h"
|
#include "base/io/json/JsonChain.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/kernel/config/BaseTransform.h"
|
#include "base/kernel/config/BaseConfig.h"
|
||||||
#include "base/kernel/interfaces/IConfig.h"
|
#include "base/kernel/interfaces/IConfig.h"
|
||||||
#include "base/kernel/Process.h"
|
#include "base/kernel/Process.h"
|
||||||
#include "base/net/stratum/Pool.h"
|
#include "base/net/stratum/Pool.h"
|
||||||
|
#include "base/net/stratum/Pools.h"
|
||||||
#include "core/config/Config_platform.h"
|
#include "core/config/Config_platform.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig
|
|
||||||
{
|
|
||||||
|
|
||||||
static const char *kAlgo = "algo";
|
|
||||||
static const char *kApi = "api";
|
|
||||||
static const char *kCoin = "coin";
|
|
||||||
static const char *kHttp = "http";
|
|
||||||
static const char *kPools = "pools";
|
|
||||||
|
|
||||||
} // namespace xmrig
|
|
||||||
|
|
||||||
|
|
||||||
void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTransform &transform)
|
void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTransform &transform)
|
||||||
{
|
{
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
@ -95,26 +85,26 @@ void xmrig::BaseTransform::finalize(rapidjson::Document &doc)
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
if (m_algorithm.isValid() && doc.HasMember(kPools)) {
|
if (m_algorithm.isValid() && doc.HasMember(Pools::kPools)) {
|
||||||
auto &pools = doc[kPools];
|
auto &pools = doc[Pools::kPools];
|
||||||
for (Value &pool : pools.GetArray()) {
|
for (Value &pool : pools.GetArray()) {
|
||||||
if (!pool.HasMember(kAlgo)) {
|
if (!pool.HasMember(Pool::kAlgo)) {
|
||||||
pool.AddMember(StringRef(kAlgo), m_algorithm.toJSON(), allocator);
|
pool.AddMember(StringRef(Pool::kAlgo), m_algorithm.toJSON(), allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_coin.isValid() && doc.HasMember(kPools)) {
|
if (m_coin.isValid() && doc.HasMember(Pools::kPools)) {
|
||||||
auto &pools = doc[kPools];
|
auto &pools = doc[Pools::kPools];
|
||||||
for (Value &pool : pools.GetArray()) {
|
for (Value &pool : pools.GetArray()) {
|
||||||
if (!pool.HasMember(kCoin)) {
|
if (!pool.HasMember(Pool::kCoin)) {
|
||||||
pool.AddMember(StringRef(kCoin), m_coin.toJSON(), allocator);
|
pool.AddMember(StringRef(Pool::kCoin), m_coin.toJSON(), allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_http) {
|
if (m_http) {
|
||||||
set(doc, kHttp, "enabled", true);
|
set(doc, BaseConfig::kHttp, Http::kEnabled, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,20 +113,20 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case IConfig::AlgorithmKey: /* --algo */
|
case IConfig::AlgorithmKey: /* --algo */
|
||||||
if (!doc.HasMember(kPools)) {
|
if (!doc.HasMember(Pools::kPools)) {
|
||||||
m_algorithm = arg;
|
m_algorithm = arg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return add(doc, kPools, kAlgo, arg);
|
return add(doc, Pools::kPools, Pool::kAlgo, arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IConfig::CoinKey: /* --coin */
|
case IConfig::CoinKey: /* --coin */
|
||||||
if (!doc.HasMember(kPools)) {
|
if (!doc.HasMember(Pools::kPools)) {
|
||||||
m_coin = arg;
|
m_coin = arg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return add(doc, kPools, kCoin, arg);
|
return add(doc, Pools::kPools, Pool::kCoin, arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -150,61 +140,61 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
char *user = new char[p - arg + 1]();
|
char *user = new char[p - arg + 1]();
|
||||||
strncpy(user, arg, static_cast<size_t>(p - arg));
|
strncpy(user, arg, static_cast<size_t>(p - arg));
|
||||||
|
|
||||||
add<const char *>(doc, kPools, "user", user);
|
add<const char *>(doc, Pools::kPools, Pool::kUser, user);
|
||||||
add(doc, kPools, "pass", p + 1);
|
add(doc, Pools::kPools, Pool::kPass, p + 1);
|
||||||
delete [] user;
|
delete [] user;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IConfig::UrlKey: /* --url */
|
case IConfig::UrlKey: /* --url */
|
||||||
{
|
{
|
||||||
if (!doc.HasMember(kPools)) {
|
if (!doc.HasMember(Pools::kPools)) {
|
||||||
doc.AddMember(rapidjson::StringRef(kPools), rapidjson::kArrayType, doc.GetAllocator());
|
doc.AddMember(rapidjson::StringRef(Pools::kPools), rapidjson::kArrayType, doc.GetAllocator());
|
||||||
}
|
}
|
||||||
|
|
||||||
rapidjson::Value &array = doc[kPools];
|
rapidjson::Value &array = doc[Pools::kPools];
|
||||||
if (array.Size() == 0 || Pool(array[array.Size() - 1]).isValid()) {
|
if (array.Size() == 0 || Pool(array[array.Size() - 1]).isValid()) {
|
||||||
array.PushBack(rapidjson::kObjectType, doc.GetAllocator());
|
array.PushBack(rapidjson::kObjectType, doc.GetAllocator());
|
||||||
}
|
}
|
||||||
|
|
||||||
set(doc, array[array.Size() - 1], "url", arg);
|
set(doc, array[array.Size() - 1], Pool::kUrl, arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IConfig::UserKey: /* --user */
|
case IConfig::UserKey: /* --user */
|
||||||
return add(doc, kPools, "user", arg);
|
return add(doc, Pools::kPools, Pool::kUser, arg);
|
||||||
|
|
||||||
case IConfig::PasswordKey: /* --pass */
|
case IConfig::PasswordKey: /* --pass */
|
||||||
return add(doc, kPools, "pass", arg);
|
return add(doc, Pools::kPools, Pool::kPass, arg);
|
||||||
|
|
||||||
case IConfig::RigIdKey: /* --rig-id */
|
case IConfig::RigIdKey: /* --rig-id */
|
||||||
return add(doc, kPools, "rig-id", arg);
|
return add(doc, Pools::kPools, Pool::kRigId, arg);
|
||||||
|
|
||||||
case IConfig::FingerprintKey: /* --tls-fingerprint */
|
case IConfig::FingerprintKey: /* --tls-fingerprint */
|
||||||
return add(doc, kPools, "tls-fingerprint", arg);
|
return add(doc, Pools::kPools, Pool::kFingerprint, arg);
|
||||||
|
|
||||||
case IConfig::SelfSelectKey: /* --self-select */
|
case IConfig::SelfSelectKey: /* --self-select */
|
||||||
return add(doc, kPools, "self-select", arg);
|
return add(doc, Pools::kPools, Pool::kSelfSelect, arg);
|
||||||
|
|
||||||
case IConfig::LogFileKey: /* --log-file */
|
case IConfig::LogFileKey: /* --log-file */
|
||||||
return set(doc, "log-file", arg);
|
return set(doc, BaseConfig::kLogFile, arg);
|
||||||
|
|
||||||
case IConfig::HttpAccessTokenKey: /* --http-access-token */
|
case IConfig::HttpAccessTokenKey: /* --http-access-token */
|
||||||
m_http = true;
|
m_http = true;
|
||||||
return set(doc, kHttp, "access-token", arg);
|
return set(doc, BaseConfig::kHttp, Http::kToken, arg);
|
||||||
|
|
||||||
case IConfig::HttpHostKey: /* --http-host */
|
case IConfig::HttpHostKey: /* --http-host */
|
||||||
m_http = true;
|
m_http = true;
|
||||||
return set(doc, kHttp, "host", arg);
|
return set(doc, BaseConfig::kHttp, Http::kHost, arg);
|
||||||
|
|
||||||
case IConfig::ApiWorkerIdKey: /* --api-worker-id */
|
case IConfig::ApiWorkerIdKey: /* --api-worker-id */
|
||||||
return set(doc, kApi, "worker-id", arg);
|
return set(doc, BaseConfig::kApi, BaseConfig::kApiWorkerId, arg);
|
||||||
|
|
||||||
case IConfig::ApiIdKey: /* --api-id */
|
case IConfig::ApiIdKey: /* --api-id */
|
||||||
return set(doc, kApi, "id", arg);
|
return set(doc, BaseConfig::kApi, BaseConfig::kApiId, arg);
|
||||||
|
|
||||||
case IConfig::UserAgentKey: /* --user-agent */
|
case IConfig::UserAgentKey: /* --user-agent */
|
||||||
return set(doc, "user-agent", arg);
|
return set(doc, BaseConfig::kUserAgent, arg);
|
||||||
|
|
||||||
case IConfig::RetriesKey: /* --retries */
|
case IConfig::RetriesKey: /* --retries */
|
||||||
case IConfig::RetryPauseKey: /* --retry-pause */
|
case IConfig::RetryPauseKey: /* --retry-pause */
|
||||||
|
@ -222,6 +212,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
case IConfig::DryRunKey: /* --dry-run */
|
case IConfig::DryRunKey: /* --dry-run */
|
||||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||||
case IConfig::DaemonKey: /* --daemon */
|
case IConfig::DaemonKey: /* --daemon */
|
||||||
|
case IConfig::VerboseKey: /* --verbose */
|
||||||
return transformBoolean(doc, key, true);
|
return transformBoolean(doc, key, true);
|
||||||
|
|
||||||
case IConfig::ColorKey: /* --no-color */
|
case IConfig::ColorKey: /* --no-color */
|
||||||
|
@ -238,40 +229,43 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case IConfig::BackgroundKey: /* --background */
|
case IConfig::BackgroundKey: /* --background */
|
||||||
return set(doc, "background", enable);
|
return set(doc, BaseConfig::kBackground, enable);
|
||||||
|
|
||||||
case IConfig::SyslogKey: /* --syslog */
|
case IConfig::SyslogKey: /* --syslog */
|
||||||
return set(doc, "syslog", enable);
|
return set(doc, BaseConfig::kSyslog, enable);
|
||||||
|
|
||||||
case IConfig::KeepAliveKey: /* --keepalive */
|
case IConfig::KeepAliveKey: /* --keepalive */
|
||||||
return add(doc, kPools, "keepalive", enable);
|
return add(doc, Pools::kPools, Pool::kKeepalive, enable);
|
||||||
|
|
||||||
case IConfig::TlsKey: /* --tls */
|
case IConfig::TlsKey: /* --tls */
|
||||||
return add(doc, kPools, "tls", enable);
|
return add(doc, Pools::kPools, Pool::kTls, enable);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
case IConfig::DaemonKey: /* --daemon */
|
case IConfig::DaemonKey: /* --daemon */
|
||||||
return add(doc, kPools, "daemon", enable);
|
return add(doc, Pools::kPools, Pool::kDaemon, enable);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_PROXY_PROJECT
|
# ifndef XMRIG_PROXY_PROJECT
|
||||||
case IConfig::NicehashKey: /* --nicehash */
|
case IConfig::NicehashKey: /* --nicehash */
|
||||||
return add<bool>(doc, kPools, "nicehash", enable);
|
return add<bool>(doc, Pools::kPools, Pool::kNicehash, enable);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
case IConfig::ColorKey: /* --no-color */
|
case IConfig::ColorKey: /* --no-color */
|
||||||
return set(doc, "colors", enable);
|
return set(doc, BaseConfig::kColors, enable);
|
||||||
|
|
||||||
case IConfig::HttpRestrictedKey: /* --http-no-restricted */
|
case IConfig::HttpRestrictedKey: /* --http-no-restricted */
|
||||||
m_http = true;
|
m_http = true;
|
||||||
return set(doc, kHttp, "restricted", enable);
|
return set(doc, BaseConfig::kHttp, Http::kRestricted, enable);
|
||||||
|
|
||||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||||
m_http = true;
|
m_http = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IConfig::DryRunKey: /* --dry-run */
|
case IConfig::DryRunKey: /* --dry-run */
|
||||||
return set(doc, "dry-run", enable);
|
return set(doc, BaseConfig::kDryRun, enable);
|
||||||
|
|
||||||
|
case IConfig::VerboseKey: /* --verbose */
|
||||||
|
return set(doc, BaseConfig::kVerbose, enable);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -283,27 +277,27 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case IConfig::RetriesKey: /* --retries */
|
case IConfig::RetriesKey: /* --retries */
|
||||||
return set(doc, "retries", arg);
|
return set(doc, Pools::kRetries, arg);
|
||||||
|
|
||||||
case IConfig::RetryPauseKey: /* --retry-pause */
|
case IConfig::RetryPauseKey: /* --retry-pause */
|
||||||
return set(doc, "retry-pause", arg);
|
return set(doc, Pools::kRetryPause, arg);
|
||||||
|
|
||||||
case IConfig::DonateLevelKey: /* --donate-level */
|
case IConfig::DonateLevelKey: /* --donate-level */
|
||||||
return set(doc, "donate-level", arg);
|
return set(doc, Pools::kDonateLevel, arg);
|
||||||
|
|
||||||
case IConfig::ProxyDonateKey: /* --donate-over-proxy */
|
case IConfig::ProxyDonateKey: /* --donate-over-proxy */
|
||||||
return set(doc, "donate-over-proxy", arg);
|
return set(doc, Pools::kDonateOverProxy, arg);
|
||||||
|
|
||||||
case IConfig::HttpPort: /* --http-port */
|
case IConfig::HttpPort: /* --http-port */
|
||||||
m_http = true;
|
m_http = true;
|
||||||
return set(doc, kHttp, "port", arg);
|
return set(doc, BaseConfig::kHttp, Http::kPort, arg);
|
||||||
|
|
||||||
case IConfig::PrintTimeKey: /* --print-time */
|
case IConfig::PrintTimeKey: /* --print-time */
|
||||||
return set(doc, "print-time", arg);
|
return set(doc, BaseConfig::kPrintTime, arg);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||||
return add(doc, kPools, "daemon-poll-interval", arg);
|
return add(doc, Pools::kPools, Pool::kDaemonPollInterval, arg);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -92,6 +92,7 @@ public:
|
||||||
RandomXModeKey = 1029,
|
RandomXModeKey = 1029,
|
||||||
RandomX1GbPagesKey = 1031,
|
RandomX1GbPagesKey = 1031,
|
||||||
RandomXWrmsrKey = 1032,
|
RandomXWrmsrKey = 1032,
|
||||||
|
RandomXRdmsrKey = 1033,
|
||||||
CPUMaxThreadsKey = 1026,
|
CPUMaxThreadsKey = 1026,
|
||||||
MemoryPoolKey = 1027,
|
MemoryPoolKey = 1027,
|
||||||
YieldKey = 1030,
|
YieldKey = 1030,
|
||||||
|
@ -114,6 +115,7 @@ public:
|
||||||
AccessLogFileKey = 'A',
|
AccessLogFileKey = 'A',
|
||||||
BindKey = 'b',
|
BindKey = 'b',
|
||||||
CustomDiffKey = 1102,
|
CustomDiffKey = 1102,
|
||||||
|
CustomDiffStatsKey = 1104,
|
||||||
DebugKey = 1101,
|
DebugKey = 1101,
|
||||||
ModeKey = 'm',
|
ModeKey = 'm',
|
||||||
PoolCoinKey = 'C',
|
PoolCoinKey = 'C',
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -30,12 +30,14 @@
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
static const char *kEnabled = "enabled";
|
|
||||||
static const char *kHost = "host";
|
const char *Http::kEnabled = "enabled";
|
||||||
static const char *kLocalhost = "127.0.0.1";
|
const char *Http::kHost = "host";
|
||||||
static const char *kPort = "port";
|
const char *Http::kLocalhost = "127.0.0.1";
|
||||||
static const char *kRestricted = "restricted";
|
const char *Http::kPort = "port";
|
||||||
static const char *kToken = "access-token";
|
const char *Http::kRestricted = "restricted";
|
||||||
|
const char *Http::kToken = "access-token";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,6 +36,13 @@ namespace xmrig {
|
||||||
class Http
|
class Http
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const char *kEnabled;
|
||||||
|
static const char *kHost;
|
||||||
|
static const char *kLocalhost;
|
||||||
|
static const char *kPort;
|
||||||
|
static const char *kRestricted;
|
||||||
|
static const char *kToken;
|
||||||
|
|
||||||
Http();
|
Http();
|
||||||
|
|
||||||
inline bool isAuthRequired() const { return !m_restricted || !m_token.isNull(); }
|
inline bool isAuthRequired() const { return !m_restricted || !m_token.isNull(); }
|
||||||
|
|
|
@ -23,16 +23,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
|
||||||
#include "base/net/stratum/BaseClient.h"
|
#include "base/net/stratum/BaseClient.h"
|
||||||
|
#include "base/kernel/Env.h"
|
||||||
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
#include "base/net/stratum/SubmitResult.h"
|
#include "base/net/stratum/SubmitResult.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
int64_t BaseClient::m_sequence = 1;
|
int64_t BaseClient::m_sequence = 1;
|
||||||
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +46,19 @@ xmrig::BaseClient::BaseClient(int id, IClientListener *listener) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::BaseClient::setPool(const Pool &pool)
|
||||||
|
{
|
||||||
|
if (!pool.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pool = pool;
|
||||||
|
m_user = Env::expand(pool.user());
|
||||||
|
m_password = Env::expand(pool.password());
|
||||||
|
m_rigId = Env::expand(pool.rigId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::BaseClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
bool xmrig::BaseClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error)
|
||||||
{
|
{
|
||||||
if (id == 1) {
|
if (id == 1) {
|
||||||
|
|
|
@ -56,11 +56,12 @@ protected:
|
||||||
inline int64_t sequence() const override { return m_sequence; }
|
inline int64_t sequence() const override { return m_sequence; }
|
||||||
inline void setAlgo(const Algorithm &algo) override { m_pool.setAlgo(algo); }
|
inline void setAlgo(const Algorithm &algo) override { m_pool.setAlgo(algo); }
|
||||||
inline void setEnabled(bool enabled) override { m_enabled = enabled; }
|
inline void setEnabled(bool enabled) override { m_enabled = enabled; }
|
||||||
inline void setPool(const Pool &pool) override { if (pool.isValid()) { m_pool = pool; } }
|
|
||||||
inline void setQuiet(bool quiet) override { m_quiet = quiet; }
|
inline void setQuiet(bool quiet) override { m_quiet = quiet; }
|
||||||
inline void setRetries(int retries) override { m_retries = retries; }
|
inline void setRetries(int retries) override { m_retries = retries; }
|
||||||
inline void setRetryPause(uint64_t ms) override { m_retryPause = ms; }
|
inline void setRetryPause(uint64_t ms) override { m_retryPause = ms; }
|
||||||
|
|
||||||
|
void setPool(const Pool &pool) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum SocketState {
|
enum SocketState {
|
||||||
UnconnectedState,
|
UnconnectedState,
|
||||||
|
@ -95,6 +96,9 @@ protected:
|
||||||
std::map<int64_t, SendResult> m_callbacks;
|
std::map<int64_t, SendResult> m_callbacks;
|
||||||
std::map<int64_t, SubmitResult> m_results;
|
std::map<int64_t, SubmitResult> m_results;
|
||||||
String m_ip;
|
String m_ip;
|
||||||
|
String m_password;
|
||||||
|
String m_rigId;
|
||||||
|
String m_user;
|
||||||
uint64_t m_retryPause = 5000;
|
uint64_t m_retryPause = 5000;
|
||||||
|
|
||||||
static int64_t m_sequence;
|
static int64_t m_sequence;
|
||||||
|
|
|
@ -79,7 +79,8 @@ static const char *states[] = {
|
||||||
|
|
||||||
xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||||
BaseClient(id, listener),
|
BaseClient(id, listener),
|
||||||
m_agent(agent)
|
m_agent(agent),
|
||||||
|
m_sendBuf(1024)
|
||||||
{
|
{
|
||||||
m_key = m_storage.add(this);
|
m_key = m_storage.add(this);
|
||||||
m_dns = new Dns(this);
|
m_dns = new Dns(this);
|
||||||
|
@ -158,13 +159,18 @@ int64_t xmrig::Client::send(const rapidjson::Value &obj)
|
||||||
obj.Accept(writer);
|
obj.Accept(writer);
|
||||||
|
|
||||||
const size_t size = buffer.GetSize();
|
const size_t size = buffer.GetSize();
|
||||||
if (size > (sizeof(m_sendBuf) - 2)) {
|
if (size > kMaxSendBufferSize) {
|
||||||
LOG_ERR("[%s] send failed: \"send buffer overflow: %zu > %zu\"", url(), size, (sizeof(m_sendBuf) - 2));
|
LOG_ERR("[%s] send failed: \"max send buffer size exceeded: %zu\"", url(), size);
|
||||||
close();
|
close();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(m_sendBuf, buffer.GetString(), size);
|
if (size > (m_sendBuf.size() - 2)) {
|
||||||
|
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(m_sendBuf.data(), buffer.GetString(), size);
|
||||||
m_sendBuf[size] = '\n';
|
m_sendBuf[size] = '\n';
|
||||||
m_sendBuf[size + 1] = '\0';
|
m_sendBuf[size + 1] = '\0';
|
||||||
|
|
||||||
|
@ -186,8 +192,8 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
||||||
const char *nonce = result.nonce;
|
const char *nonce = result.nonce;
|
||||||
const char *data = result.result;
|
const char *data = result.result;
|
||||||
# else
|
# else
|
||||||
char *nonce = m_sendBuf;
|
char *nonce = m_sendBuf.data();
|
||||||
char *data = m_sendBuf + 16;
|
char *data = m_sendBuf.data() + 16;
|
||||||
|
|
||||||
Buffer::toHex(reinterpret_cast<const char*>(&result.nonce), 4, nonce);
|
Buffer::toHex(reinterpret_cast<const char*>(&result.nonce), 4, nonce);
|
||||||
nonce[8] = '\0';
|
nonce[8] = '\0';
|
||||||
|
@ -460,11 +466,7 @@ bool xmrig::Client::send(BIO *bio)
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (state() == ConnectedState && uv_is_writable(m_stream)) {
|
if (state() == ConnectedState && uv_is_writable(m_stream)) {
|
||||||
result = uv_try_write(m_stream, &buf, 1) > 0;
|
result = write(buf);
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG_DEBUG_ERR("[%s] send failed, invalid state: %d", url(), m_state);
|
LOG_DEBUG_ERR("[%s] send failed, invalid state: %d", url(), m_state);
|
||||||
|
@ -505,6 +507,23 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Client::write(const uv_buf_t &buf)
|
||||||
|
{
|
||||||
|
const int rc = uv_try_write(m_stream, &buf, 1);
|
||||||
|
if (static_cast<size_t>(rc) == buf.len) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isQuiet()) {
|
||||||
|
LOG_ERR("[%s] write error: \"%s\"", url(), uv_strerror(rc));
|
||||||
|
}
|
||||||
|
|
||||||
|
close();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int xmrig::Client::resolve(const String &host)
|
int xmrig::Client::resolve(const String &host)
|
||||||
{
|
{
|
||||||
setState(HostLookupState);
|
setState(HostLookupState);
|
||||||
|
@ -529,11 +548,11 @@ int xmrig::Client::resolve(const String &host)
|
||||||
|
|
||||||
int64_t xmrig::Client::send(size_t size)
|
int64_t xmrig::Client::send(size_t size)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("[%s] send (%d bytes): \"%.*s\"", url(), size, static_cast<int>(size) - 1, m_sendBuf);
|
LOG_DEBUG("[%s] send (%d bytes): \"%.*s\"", url(), size, static_cast<int>(size) - 1, m_sendBuf.data());
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
if (isTLS()) {
|
if (isTLS()) {
|
||||||
if (!m_tls->send(m_sendBuf, size)) {
|
if (!m_tls->send(m_sendBuf.data(), size)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,10 +564,9 @@ int64_t xmrig::Client::send(size_t size)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_buf_t buf = uv_buf_init(m_sendBuf, (unsigned int) size);
|
uv_buf_t buf = uv_buf_init(m_sendBuf.data(), (unsigned int) size);
|
||||||
|
|
||||||
if (uv_try_write(m_stream, &buf, 1) < 0) {
|
if (!write(buf)) {
|
||||||
close();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,12 +624,12 @@ void xmrig::Client::login()
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
Value params(kObjectType);
|
Value params(kObjectType);
|
||||||
params.AddMember("login", m_pool.user().toJSON(), allocator);
|
params.AddMember("login", m_user.toJSON(), allocator);
|
||||||
params.AddMember("pass", m_pool.password().toJSON(), allocator);
|
params.AddMember("pass", m_password.toJSON(), allocator);
|
||||||
params.AddMember("agent", StringRef(m_agent), allocator);
|
params.AddMember("agent", StringRef(m_agent), allocator);
|
||||||
|
|
||||||
if (!m_pool.rigId().isNull()) {
|
if (!m_rigId.isNull()) {
|
||||||
params.AddMember("rigid", m_pool.rigId().toJSON(), allocator);
|
params.AddMember("rigid", m_rigId.toJSON(), allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_listener->onLogin(this, doc, params);
|
m_listener->onLogin(this, doc, params);
|
||||||
|
@ -795,7 +813,7 @@ void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, co
|
||||||
|
|
||||||
void xmrig::Client::ping()
|
void xmrig::Client::ping()
|
||||||
{
|
{
|
||||||
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
send(snprintf(m_sendBuf.data(), m_sendBuf.size(), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
||||||
|
|
||||||
m_keepAlive = 0;
|
m_keepAlive = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,8 @@ public:
|
||||||
|
|
||||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
|
||||||
constexpr static size_t kInputBufferSize = 1024 * 16;
|
constexpr static size_t kInputBufferSize = 1024 * 16;
|
||||||
# else
|
constexpr static size_t kMaxSendBufferSize = 1024 * 16;
|
||||||
constexpr static size_t kInputBufferSize = 1024 * 2;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
Client(int id, const char *agent, IClientListener *listener);
|
Client(int id, const char *agent, IClientListener *listener);
|
||||||
~Client() override;
|
~Client() override;
|
||||||
|
@ -100,6 +96,7 @@ private:
|
||||||
bool parseLogin(const rapidjson::Value &result, int *code);
|
bool parseLogin(const rapidjson::Value &result, int *code);
|
||||||
bool send(BIO *bio);
|
bool send(BIO *bio);
|
||||||
bool verifyAlgorithm(const Algorithm &algorithm, const char *algo) const;
|
bool verifyAlgorithm(const Algorithm &algorithm, const char *algo) const;
|
||||||
|
bool write(const uv_buf_t &buf);
|
||||||
int resolve(const String &host);
|
int resolve(const String &host);
|
||||||
int64_t send(size_t size);
|
int64_t send(size_t size);
|
||||||
void connect(sockaddr *addr);
|
void connect(sockaddr *addr);
|
||||||
|
@ -128,11 +125,11 @@ private:
|
||||||
|
|
||||||
static inline Client *getClient(void *data) { return m_storage.get(data); }
|
static inline Client *getClient(void *data) { return m_storage.get(data); }
|
||||||
|
|
||||||
char m_sendBuf[4096] = { 0 };
|
|
||||||
const char *m_agent;
|
const char *m_agent;
|
||||||
Dns *m_dns;
|
Dns *m_dns;
|
||||||
RecvBuf<kInputBufferSize> m_recvBuf;
|
RecvBuf<kInputBufferSize> m_recvBuf;
|
||||||
std::bitset<EXT_MAX> m_extensions;
|
std::bitset<EXT_MAX> m_extensions;
|
||||||
|
std::vector<char> m_sendBuf;
|
||||||
String m_rpcId;
|
String m_rpcId;
|
||||||
Tls *m_tls = nullptr;
|
Tls *m_tls = nullptr;
|
||||||
uint64_t m_expire = 0;
|
uint64_t m_expire = 0;
|
||||||
|
|
|
@ -284,7 +284,7 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
Value params(kObjectType);
|
Value params(kObjectType);
|
||||||
params.AddMember("wallet_address", m_pool.user().toJSON(), allocator);
|
params.AddMember("wallet_address", m_user.toJSON(), allocator);
|
||||||
params.AddMember("reserve_size", 8, allocator);
|
params.AddMember("reserve_size", 8, allocator);
|
||||||
|
|
||||||
JsonRequest::create(doc, m_sequence, "getblocktemplate", params);
|
JsonRequest::create(doc, m_sequence, "getblocktemplate", params);
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -47,24 +47,27 @@
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
static const char *kAlgo = "algo";
|
|
||||||
static const char *kCoin = "coin";
|
|
||||||
static const char *kDaemon = "daemon";
|
|
||||||
static const char *kDaemonPollInterval = "daemon-poll-interval";
|
|
||||||
static const char *kEnabled = "enabled";
|
|
||||||
static const char *kFingerprint = "tls-fingerprint";
|
|
||||||
static const char *kKeepalive = "keepalive";
|
|
||||||
static const char *kNicehash = "nicehash";
|
|
||||||
static const char *kPass = "pass";
|
|
||||||
static const char *kRigId = "rig-id";
|
|
||||||
static const char *kSelfSelect = "self-select";
|
|
||||||
static const char *kTls = "tls";
|
|
||||||
static const char *kUrl = "url";
|
|
||||||
static const char *kUser = "user";
|
|
||||||
|
|
||||||
const String Pool::kDefaultPassword = "x";
|
const String Pool::kDefaultPassword = "x";
|
||||||
const String Pool::kDefaultUser = "x";
|
const String Pool::kDefaultUser = "x";
|
||||||
|
|
||||||
|
|
||||||
|
const char *Pool::kAlgo = "algo";
|
||||||
|
const char *Pool::kCoin = "coin";
|
||||||
|
const char *Pool::kDaemon = "daemon";
|
||||||
|
const char *Pool::kDaemonPollInterval = "daemon-poll-interval";
|
||||||
|
const char *Pool::kEnabled = "enabled";
|
||||||
|
const char *Pool::kFingerprint = "tls-fingerprint";
|
||||||
|
const char *Pool::kKeepalive = "keepalive";
|
||||||
|
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::kTls = "tls";
|
||||||
|
const char *Pool::kUrl = "url";
|
||||||
|
const char *Pool::kUser = "user";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -55,6 +55,21 @@ public:
|
||||||
static const String kDefaultPassword;
|
static const String kDefaultPassword;
|
||||||
static const String kDefaultUser;
|
static const String kDefaultUser;
|
||||||
|
|
||||||
|
static const char *kAlgo;
|
||||||
|
static const char *kCoin;
|
||||||
|
static const char *kDaemon;
|
||||||
|
static const char *kDaemonPollInterval;
|
||||||
|
static const char *kEnabled;
|
||||||
|
static const char *kFingerprint;
|
||||||
|
static const char *kKeepalive;
|
||||||
|
static const char *kNicehash;
|
||||||
|
static const char *kPass;
|
||||||
|
static const char *kRigId;
|
||||||
|
static const char *kSelfSelect;
|
||||||
|
static const char *kTls;
|
||||||
|
static const char *kUrl;
|
||||||
|
static const char *kUser;
|
||||||
|
|
||||||
constexpr static int kKeepAliveTimeout = 60;
|
constexpr static int kKeepAliveTimeout = 60;
|
||||||
constexpr static uint16_t kDefaultPort = 3333;
|
constexpr static uint16_t kDefaultPort = 3333;
|
||||||
constexpr static uint64_t kDefaultPollInterval = 1000;
|
constexpr static uint64_t kDefaultPollInterval = 1000;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,20 +23,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/Pools.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/kernel/interfaces/IJsonReader.h"
|
#include "base/kernel/interfaces/IJsonReader.h"
|
||||||
#include "base/net/stratum/Pools.h"
|
|
||||||
#include "base/net/stratum/strategies/FailoverStrategy.h"
|
#include "base/net/stratum/strategies/FailoverStrategy.h"
|
||||||
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
|
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
|
||||||
#include "donate.h"
|
#include "donate.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
const char *Pools::kDonateLevel = "donate-level";
|
||||||
|
const char *Pools::kDonateOverProxy = "donate-over-proxy";
|
||||||
|
const char *Pools::kPools = "pools";
|
||||||
|
const char *Pools::kRetries = "retries";
|
||||||
|
const char *Pools::kRetryPause = "retry-pause";
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
xmrig::Pools::Pools() :
|
xmrig::Pools::Pools() :
|
||||||
m_donateLevel(kDefaultDonateLevel),
|
m_donateLevel(kDefaultDonateLevel)
|
||||||
m_retries(5),
|
|
||||||
m_retryPause(5),
|
|
||||||
m_proxyDonate(PROXY_DONATE_AUTO)
|
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_PROXY_PROJECT
|
# ifdef XMRIG_PROXY_PROJECT
|
||||||
m_retries = 2;
|
m_retries = 2;
|
||||||
|
@ -108,7 +118,7 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
{
|
{
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
|
|
||||||
const rapidjson::Value &pools = reader.getArray("pools");
|
const rapidjson::Value &pools = reader.getArray(kPools);
|
||||||
if (!pools.IsArray()) {
|
if (!pools.IsArray()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -124,10 +134,10 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDonateLevel(reader.getInt("donate-level", kDefaultDonateLevel));
|
setDonateLevel(reader.getInt(kDonateLevel, kDefaultDonateLevel));
|
||||||
setProxyDonate(reader.getInt("donate-over-proxy", PROXY_DONATE_AUTO));
|
setProxyDonate(reader.getInt(kDonateOverProxy, PROXY_DONATE_AUTO));
|
||||||
setRetries(reader.getInt("retries"));
|
setRetries(reader.getInt(kRetries));
|
||||||
setRetryPause(reader.getInt("retry-pause"));
|
setRetryPause(reader.getInt(kRetryPause));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -43,6 +43,12 @@ class IStrategyListener;
|
||||||
class Pools
|
class Pools
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const char *kDonateLevel;
|
||||||
|
static const char *kDonateOverProxy;
|
||||||
|
static const char *kPools;
|
||||||
|
static const char *kRetries;
|
||||||
|
static const char *kRetryPause;
|
||||||
|
|
||||||
enum ProxyDonate {
|
enum ProxyDonate {
|
||||||
PROXY_DONATE_NONE,
|
PROXY_DONATE_NONE,
|
||||||
PROXY_DONATE_AUTO,
|
PROXY_DONATE_AUTO,
|
||||||
|
@ -74,9 +80,9 @@ private:
|
||||||
void setRetryPause(int retryPause);
|
void setRetryPause(int retryPause);
|
||||||
|
|
||||||
int m_donateLevel;
|
int m_donateLevel;
|
||||||
int m_retries;
|
int m_retries = 5;
|
||||||
int m_retryPause;
|
int m_retryPause = 5;
|
||||||
ProxyDonate m_proxyDonate;
|
ProxyDonate m_proxyDonate = PROXY_DONATE_AUTO;
|
||||||
std::vector<Pool> m_data;
|
std::vector<Pool> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"init": -1,
|
"init": -1,
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"1gb-pages": false,
|
"1gb-pages": false,
|
||||||
|
"rdmsr": true,
|
||||||
"wrmsr": true,
|
"wrmsr": true,
|
||||||
"numa": true
|
"numa": true
|
||||||
},
|
},
|
||||||
|
@ -74,5 +75,6 @@
|
||||||
"retry-pause": 5,
|
"retry-pause": 5,
|
||||||
"syslog": false,
|
"syslog": false,
|
||||||
"user-agent": null,
|
"user-agent": null,
|
||||||
|
"verbose": 0,
|
||||||
"watch": true
|
"watch": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -123,6 +123,10 @@ public:
|
||||||
|
|
||||||
inline void handleJobChange()
|
inline void handleJobChange()
|
||||||
{
|
{
|
||||||
|
if (!enabled) {
|
||||||
|
Nonce::pause(true);
|
||||||
|
}
|
||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
|
@ -136,7 +140,7 @@ public:
|
||||||
Nonce::touch();
|
Nonce::touch();
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
Nonce::pause(false);;
|
Nonce::pause(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticks == 0) {
|
if (ticks == 0) {
|
||||||
|
@ -262,6 +266,7 @@ xmrig::Miner::Miner(Controller *controller)
|
||||||
{
|
{
|
||||||
const int priority = controller->config()->cpu().priority();
|
const int priority = controller->config()->cpu().priority();
|
||||||
if (priority >= 0) {
|
if (priority >= 0) {
|
||||||
|
Platform::setProcessPriority(priority);
|
||||||
Platform::setThreadPriority(std::min(priority + 1, 5));
|
Platform::setThreadPriority(std::min(priority + 1, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -211,14 +211,14 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
Value api(kObjectType);
|
Value api(kObjectType);
|
||||||
api.AddMember("id", m_apiId.toJSON(), allocator);
|
api.AddMember(StringRef(kApiId), m_apiId.toJSON(), allocator);
|
||||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
api.AddMember(StringRef(kApiWorkerId), m_apiWorkerId.toJSON(), allocator);
|
||||||
|
|
||||||
doc.AddMember("api", api, allocator);
|
doc.AddMember(StringRef(kApi), api, allocator);
|
||||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
doc.AddMember(StringRef(kHttp), m_http.toJSON(doc), allocator);
|
||||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
doc.AddMember(StringRef(kAutosave), isAutoSave(), allocator);
|
||||||
doc.AddMember("background", isBackground(), allocator);
|
doc.AddMember(StringRef(kBackground), isBackground(), allocator);
|
||||||
doc.AddMember("colors", Log::colors, allocator);
|
doc.AddMember(StringRef(kColors), Log::isColors(), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
doc.AddMember(StringRef(kRandomX), rx().toJSON(doc), allocator);
|
doc.AddMember(StringRef(kRandomX), rx().toJSON(doc), allocator);
|
||||||
|
@ -234,17 +234,18 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator);
|
doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
doc.AddMember(StringRef(Pools::kDonateLevel), m_pools.donateLevel(), allocator);
|
||||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
doc.AddMember(StringRef(Pools::kDonateOverProxy), m_pools.proxyDonate(), allocator);
|
||||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
doc.AddMember(StringRef(kLogFile), m_logFile.toJSON(), allocator);
|
||||||
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
doc.AddMember(StringRef(Pools::kPools), m_pools.toJSON(doc), allocator);
|
||||||
doc.AddMember("print-time", printTime(), allocator);
|
doc.AddMember(StringRef(kPrintTime), printTime(), allocator);
|
||||||
# if defined(XMRIG_FEATURE_NVML)
|
# if defined(XMRIG_FEATURE_NVML)
|
||||||
doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator);
|
doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator);
|
||||||
# endif
|
# endif
|
||||||
doc.AddMember("retries", m_pools.retries(), allocator);
|
doc.AddMember(StringRef(Pools::kRetries), m_pools.retries(), allocator);
|
||||||
doc.AddMember("retry-pause", m_pools.retryPause(), allocator);
|
doc.AddMember(StringRef(Pools::kRetryPause), m_pools.retryPause(), allocator);
|
||||||
doc.AddMember("syslog", isSyslog(), allocator);
|
doc.AddMember(StringRef(kSyslog), isSyslog(), allocator);
|
||||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
||||||
doc.AddMember("watch", m_watch, allocator);
|
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||||
|
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,9 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
||||||
}
|
}
|
||||||
|
|
||||||
return set(doc, kRandomX, "wrmsr", static_cast<int64_t>(strtol(arg, nullptr, 10)));
|
return set(doc, kRandomX, "wrmsr", static_cast<int64_t>(strtol(arg, nullptr, 10)));
|
||||||
|
|
||||||
|
case IConfig::RandomXRdmsrKey: /* --randomx-no-rdmsr */
|
||||||
|
return set(doc, kRandomX, "rdmsr", false);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_OPENCL
|
# ifdef XMRIG_FEATURE_OPENCL
|
||||||
|
|
|
@ -87,6 +87,7 @@ static const option options[] = {
|
||||||
{ "cpu-max-threads-hint", 1, nullptr, IConfig::CPUMaxThreadsKey },
|
{ "cpu-max-threads-hint", 1, nullptr, IConfig::CPUMaxThreadsKey },
|
||||||
{ "cpu-memory-pool", 1, nullptr, IConfig::MemoryPoolKey },
|
{ "cpu-memory-pool", 1, nullptr, IConfig::MemoryPoolKey },
|
||||||
{ "cpu-no-yield", 0, nullptr, IConfig::YieldKey },
|
{ "cpu-no-yield", 0, nullptr, IConfig::YieldKey },
|
||||||
|
{ "verbose", 0, nullptr, IConfig::VerboseKey },
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
{ "tls", 0, nullptr, IConfig::TlsKey },
|
{ "tls", 0, nullptr, IConfig::TlsKey },
|
||||||
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
|
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
|
||||||
|
@ -101,6 +102,9 @@ static const option options[] = {
|
||||||
{ "randomx-1gb-pages", 0, nullptr, IConfig::RandomX1GbPagesKey },
|
{ "randomx-1gb-pages", 0, nullptr, IConfig::RandomX1GbPagesKey },
|
||||||
{ "1gb-pages", 0, nullptr, IConfig::RandomX1GbPagesKey },
|
{ "1gb-pages", 0, nullptr, IConfig::RandomX1GbPagesKey },
|
||||||
{ "randomx-wrmsr", 2, nullptr, IConfig::RandomXWrmsrKey },
|
{ "randomx-wrmsr", 2, nullptr, IConfig::RandomXWrmsrKey },
|
||||||
|
{ "wrmsr", 2, nullptr, IConfig::RandomXWrmsrKey },
|
||||||
|
{ "randomx-no-rdmsr", 0, nullptr, IConfig::RandomXRdmsrKey },
|
||||||
|
{ "no-rdmsr", 0, nullptr, IConfig::RandomXRdmsrKey },
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_FEATURE_OPENCL
|
# ifdef XMRIG_FEATURE_OPENCL
|
||||||
{ "opencl", 0, nullptr, IConfig::OclKey },
|
{ "opencl", 0, nullptr, IConfig::OclKey },
|
||||||
|
|
|
@ -89,7 +89,8 @@ static inline const std::string &usage()
|
||||||
u += " --randomx-no-numa disable NUMA support for RandomX\n";
|
u += " --randomx-no-numa disable NUMA support for RandomX\n";
|
||||||
u += " --randomx-mode=MODE RandomX mode: auto, fast, light\n";
|
u += " --randomx-mode=MODE RandomX mode: auto, fast, light\n";
|
||||||
u += " --randomx-1gb-pages use 1GB hugepages for dataset (Linux only)\n";
|
u += " --randomx-1gb-pages use 1GB hugepages for dataset (Linux only)\n";
|
||||||
u += " --randomx-wrmsr=N write value (0-15) to Intel MSR register 0x1a4 or do nothing (-1) (Linux only)\n";
|
u += " --randomx-wrmsr=N write custom value (0-15) to Intel MSR register 0x1a4 or disable MSR mod (-1)\n";
|
||||||
|
u += " --randomx-no-rdmsr disable reverting initial MSR values on exit\n";
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
|
@ -136,6 +137,7 @@ static inline const std::string &usage()
|
||||||
u += " --health-print-time=N print health report every N seconds\n";
|
u += " --health-print-time=N print health report every N seconds\n";
|
||||||
# endif
|
# endif
|
||||||
u += " --no-color disable colored output\n";
|
u += " --no-color disable colored output\n";
|
||||||
|
u += " --verbose verbose output\n";
|
||||||
|
|
||||||
u += "\nMisc:\n";
|
u += "\nMisc:\n";
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
case Algorithm::CN_PICO_0:
|
case Algorithm::CN_PICO_0:
|
||||||
|
case Algorithm::CN_PICO_TLO:
|
||||||
return CN_ITER / 8;
|
return CN_ITER / 8;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -171,6 +172,7 @@ public:
|
||||||
case Algorithm::CN_DOUBLE:
|
case Algorithm::CN_DOUBLE:
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
case Algorithm::CN_PICO_0:
|
case Algorithm::CN_PICO_0:
|
||||||
|
case Algorithm::CN_PICO_TLO:
|
||||||
# endif
|
# endif
|
||||||
return Algorithm::CN_2;
|
return Algorithm::CN_2;
|
||||||
|
|
||||||
|
@ -217,6 +219,7 @@ template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_RWZ>::iterations() con
|
||||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() const { return 0x60000; }
|
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() const { return 0x60000; }
|
||||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::iterations() const { return 0xC000; }
|
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::iterations() const { return 0xC000; }
|
||||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; }
|
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; }
|
||||||
|
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_TLO>::iterations() const { return CN_ITER / 8; }
|
||||||
|
|
||||||
|
|
||||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_LITE_0>::memory() const { return CN_MEMORY / 2; }
|
template<> constexpr inline size_t CnAlgo<Algorithm::CN_LITE_0>::memory() const { return CN_MEMORY / 2; }
|
||||||
|
@ -225,6 +228,7 @@ template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_0>::memory() const
|
||||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_TUBE>::memory() const { return CN_MEMORY * 2; }
|
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_TUBE>::memory() const { return CN_MEMORY * 2; }
|
||||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_XHV>::memory() const { return CN_MEMORY * 2; }
|
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_XHV>::memory() const { return CN_MEMORY * 2; }
|
||||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_0>::memory() const { return CN_MEMORY / 8; }
|
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_0>::memory() const { return CN_MEMORY / 8; }
|
||||||
|
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_TLO>::memory() const { return CN_MEMORY / 8; }
|
||||||
|
|
||||||
|
|
||||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::mask() const { return 0x1FFFC0; }
|
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::mask() const { return 0x1FFFC0; }
|
||||||
|
|
|
@ -79,6 +79,11 @@ cn_mainloop_fun cn_trtl_mainloop_ryzen_asm = nullptr;
|
||||||
cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr;
|
cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr;
|
||||||
cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr;
|
cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr;
|
||||||
|
|
||||||
|
cn_mainloop_fun cn_tlo_mainloop_ivybridge_asm = nullptr;
|
||||||
|
cn_mainloop_fun cn_tlo_mainloop_ryzen_asm = nullptr;
|
||||||
|
cn_mainloop_fun cn_tlo_mainloop_bulldozer_asm = nullptr;
|
||||||
|
cn_mainloop_fun cn_tlo_double_mainloop_sandybridge_asm = nullptr;
|
||||||
|
|
||||||
cn_mainloop_fun cn_zls_mainloop_ivybridge_asm = nullptr;
|
cn_mainloop_fun cn_zls_mainloop_ivybridge_asm = nullptr;
|
||||||
cn_mainloop_fun cn_zls_mainloop_ryzen_asm = nullptr;
|
cn_mainloop_fun cn_zls_mainloop_ryzen_asm = nullptr;
|
||||||
cn_mainloop_fun cn_zls_mainloop_bulldozer_asm = nullptr;
|
cn_mainloop_fun cn_zls_mainloop_bulldozer_asm = nullptr;
|
||||||
|
@ -128,7 +133,7 @@ static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t ma
|
||||||
|
|
||||||
static void patchAsmVariants()
|
static void patchAsmVariants()
|
||||||
{
|
{
|
||||||
const int allocation_size = 65536;
|
const int allocation_size = 81920;
|
||||||
auto base = static_cast<uint8_t *>(VirtualMemory::allocateExecutableMemory(allocation_size));
|
auto base = static_cast<uint8_t *>(VirtualMemory::allocateExecutableMemory(allocation_size));
|
||||||
|
|
||||||
cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0000);
|
cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0000);
|
||||||
|
@ -153,6 +158,13 @@ static void patchAsmVariants()
|
||||||
cn_double_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xE000);
|
cn_double_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xE000);
|
||||||
cn_double_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xF000);
|
cn_double_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xF000);
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
|
cn_tlo_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x10000);
|
||||||
|
cn_tlo_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x11000);
|
||||||
|
cn_tlo_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x12000);
|
||||||
|
cn_tlo_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x13000);
|
||||||
|
# endif
|
||||||
|
|
||||||
{
|
{
|
||||||
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_HALF>().iterations();
|
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_HALF>().iterations();
|
||||||
|
|
||||||
|
@ -172,6 +184,16 @@ static void patchAsmVariants()
|
||||||
patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK);
|
patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK);
|
||||||
patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK);
|
patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_PICO_TLO>().iterations();
|
||||||
|
constexpr uint32_t MASK = CnAlgo<Algorithm::CN_PICO_TLO>().mask();
|
||||||
|
|
||||||
|
patchCode(cn_tlo_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, ITER, MASK);
|
||||||
|
patchCode(cn_tlo_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, ITER, MASK);
|
||||||
|
patchCode(cn_tlo_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK);
|
||||||
|
patchCode(cn_tlo_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -244,6 +266,8 @@ xmrig::CnHash::CnHash()
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
ADD_FN(Algorithm::CN_PICO_0);
|
ADD_FN(Algorithm::CN_PICO_0);
|
||||||
ADD_FN_ASM(Algorithm::CN_PICO_0);
|
ADD_FN_ASM(Algorithm::CN_PICO_0);
|
||||||
|
ADD_FN(Algorithm::CN_PICO_TLO);
|
||||||
|
ADD_FN_ASM(Algorithm::CN_PICO_TLO);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_ARGON2
|
# ifdef XMRIG_ALGO_ARGON2
|
||||||
|
|
|
@ -338,6 +338,21 @@ const static uint8_t test_output_pico_trtl[160] = {
|
||||||
0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5,
|
0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5,
|
||||||
0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45
|
0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// "cn-pico/tlo"
|
||||||
|
const static uint8_t test_output_pico_tlo[160] = {
|
||||||
|
0x99, 0x75, 0xF2, 0xC1, 0xB3, 0xB4, 0x54, 0x34, 0xA4, 0x93, 0x86, 0x21, 0x30, 0x97, 0xF3, 0x1B,
|
||||||
|
0xB4, 0xB9, 0xA6, 0x58, 0x6A, 0x7E, 0x81, 0xF4, 0x42, 0x9F, 0x6D, 0x5F, 0x65, 0xC3, 0x8D, 0x1A,
|
||||||
|
0xFC, 0x67, 0xDF, 0xCC, 0xB5, 0xFC, 0x90, 0xD7, 0x85, 0x5A, 0xE9, 0x03, 0x36, 0x1E, 0xAB, 0xD7,
|
||||||
|
0x6F, 0x1E, 0x40, 0xA2, 0x2A, 0x72, 0xAD, 0x3E, 0xF2, 0xD6, 0xAD, 0x27, 0xB5, 0xA6, 0x0C, 0xE5,
|
||||||
|
0x1C, 0xB1, 0x53, 0xE9, 0x70, 0x7D, 0x69, 0xF1, 0xE1, 0x55, 0x28, 0x45, 0xF5, 0x76, 0x56, 0xE5,
|
||||||
|
0x10, 0x0D, 0xEA, 0xFD, 0xD9, 0xD6, 0xAF, 0x0F, 0x47, 0x0C, 0x0D, 0xA2, 0x10, 0x16, 0x43, 0xEE,
|
||||||
|
0x25, 0x2C, 0x07, 0x3A, 0x64, 0x29, 0x16, 0xFF, 0xF5, 0xA5, 0x0B, 0xA2, 0xE0, 0xBD, 0xDC, 0xCE,
|
||||||
|
0x93, 0x3F, 0xEF, 0x6B, 0x08, 0xF4, 0x4D, 0x6A, 0x6E, 0x14, 0x13, 0x10, 0x98, 0x11, 0xE1, 0x13,
|
||||||
|
0xF6, 0x9D, 0x3D, 0x31, 0xC4, 0x3A, 0xA9, 0x44, 0x4C, 0x38, 0xAB, 0xB5, 0x4B, 0xD9, 0xFB, 0xE6,
|
||||||
|
0x98, 0xB9, 0x46, 0xE2, 0x00, 0xEB, 0x56, 0x33, 0x1E, 0xBC, 0xEB, 0xF1, 0xF6, 0x88, 0xD3, 0xF0
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -794,6 +794,11 @@ extern cn_mainloop_fun cn_trtl_mainloop_ryzen_asm;
|
||||||
extern cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm;
|
extern cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm;
|
||||||
extern cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm;
|
extern cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm;
|
||||||
|
|
||||||
|
extern cn_mainloop_fun cn_tlo_mainloop_ivybridge_asm;
|
||||||
|
extern cn_mainloop_fun cn_tlo_mainloop_ryzen_asm;
|
||||||
|
extern cn_mainloop_fun cn_tlo_mainloop_bulldozer_asm;
|
||||||
|
extern cn_mainloop_fun cn_tlo_double_mainloop_sandybridge_asm;
|
||||||
|
|
||||||
extern cn_mainloop_fun cn_zls_mainloop_ivybridge_asm;
|
extern cn_mainloop_fun cn_zls_mainloop_ivybridge_asm;
|
||||||
extern cn_mainloop_fun cn_zls_mainloop_ryzen_asm;
|
extern cn_mainloop_fun cn_zls_mainloop_ryzen_asm;
|
||||||
extern cn_mainloop_fun cn_zls_mainloop_bulldozer_asm;
|
extern cn_mainloop_fun cn_zls_mainloop_bulldozer_asm;
|
||||||
|
@ -879,6 +884,17 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
cn_trtl_mainloop_bulldozer_asm(ctx);
|
cn_trtl_mainloop_bulldozer_asm(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ALGO == Algorithm::CN_PICO_TLO) {
|
||||||
|
if (ASM == Assembly::INTEL) {
|
||||||
|
cn_tlo_mainloop_ivybridge_asm(ctx);
|
||||||
|
}
|
||||||
|
else if (ASM == Assembly::RYZEN) {
|
||||||
|
cn_tlo_mainloop_ryzen_asm(ctx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cn_tlo_mainloop_bulldozer_asm(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
else if (ALGO == Algorithm::CN_RWZ) {
|
else if (ALGO == Algorithm::CN_RWZ) {
|
||||||
cnv2_rwz_mainloop_asm(ctx);
|
cnv2_rwz_mainloop_asm(ctx);
|
||||||
|
@ -944,6 +960,9 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
else if (ALGO == Algorithm::CN_PICO_0) {
|
else if (ALGO == Algorithm::CN_PICO_0) {
|
||||||
cn_trtl_double_mainloop_sandybridge_asm(ctx);
|
cn_trtl_double_mainloop_sandybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
|
else if (ALGO == Algorithm::CN_PICO_TLO) {
|
||||||
|
cn_tlo_double_mainloop_sandybridge_asm(ctx);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
else if (ALGO == Algorithm::CN_RWZ) {
|
else if (ALGO == Algorithm::CN_RWZ) {
|
||||||
cnv2_rwz_double_mainloop_asm(ctx);
|
cnv2_rwz_double_mainloop_asm(ctx);
|
||||||
|
|
|
@ -101,6 +101,10 @@ static AlgoName const algorithm_names[] = {
|
||||||
{ "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO_0 },
|
{ "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO_0 },
|
||||||
{ "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO_0 },
|
{ "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO_0 },
|
||||||
{ "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO_0 },
|
{ "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO_0 },
|
||||||
|
{ "cryptonight-pico/tlo", "cn-pico/tlo", Algorithm::CN_PICO_TLO },
|
||||||
|
{ "cryptonight/ultra", "cn/ultra", Algorithm::CN_PICO_TLO },
|
||||||
|
{ "cryptonight-talleo", "cn-talleo", Algorithm::CN_PICO_TLO },
|
||||||
|
{ "cryptonight_talleo", "cn_talleo", Algorithm::CN_PICO_TLO },
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
{ "randomx/0", "rx/0", Algorithm::RX_0 },
|
{ "randomx/0", "rx/0", Algorithm::RX_0 },
|
||||||
|
@ -112,6 +116,8 @@ static AlgoName const algorithm_names[] = {
|
||||||
{ "RandomXL", nullptr, Algorithm::RX_LOKI },
|
{ "RandomXL", nullptr, Algorithm::RX_LOKI },
|
||||||
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
||||||
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
||||||
|
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
|
||||||
|
{ "RandomSFX", nullptr, Algorithm::RX_SFX },
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_ALGO_ARGON2
|
# ifdef XMRIG_ALGO_ARGON2
|
||||||
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||||
|
@ -138,6 +144,7 @@ size_t xmrig::Algorithm::l2() const
|
||||||
switch (m_id) {
|
switch (m_id) {
|
||||||
case RX_0:
|
case RX_0:
|
||||||
case RX_LOKI:
|
case RX_LOKI:
|
||||||
|
case RX_SFX:
|
||||||
return 0x40000;
|
return 0x40000;
|
||||||
|
|
||||||
case RX_WOW:
|
case RX_WOW:
|
||||||
|
@ -173,6 +180,7 @@ size_t xmrig::Algorithm::l3() const
|
||||||
switch (m_id) {
|
switch (m_id) {
|
||||||
case RX_0:
|
case RX_0:
|
||||||
case RX_LOKI:
|
case RX_LOKI:
|
||||||
|
case RX_SFX:
|
||||||
return oneMiB * 2;
|
return oneMiB * 2;
|
||||||
|
|
||||||
case RX_WOW:
|
case RX_WOW:
|
||||||
|
@ -264,6 +272,7 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
case CN_PICO_0:
|
case CN_PICO_0:
|
||||||
|
case CN_PICO_TLO:
|
||||||
return CN_PICO;
|
return CN_PICO;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -272,6 +281,7 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
||||||
case RX_WOW:
|
case RX_WOW:
|
||||||
case RX_LOKI:
|
case RX_LOKI:
|
||||||
case RX_ARQ:
|
case RX_ARQ:
|
||||||
|
case RX_SFX:
|
||||||
return RANDOM_X;
|
return RANDOM_X;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,13 @@ public:
|
||||||
CN_HEAVY_0, // "cn-heavy/0" CryptoNight-Heavy (4 MB).
|
CN_HEAVY_0, // "cn-heavy/0" CryptoNight-Heavy (4 MB).
|
||||||
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
||||||
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
|
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
|
||||||
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
CN_PICO_0, // "cn-pico" CryptoNight-Pico
|
||||||
|
CN_PICO_TLO, // "cn-pico/tlo" CryptoNight-Pico (TLO)
|
||||||
RX_0, // "rx/0" RandomX (reference configuration).
|
RX_0, // "rx/0" RandomX (reference configuration).
|
||||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||||
RX_LOKI, // "rx/loki" RandomXL (Loki).
|
RX_LOKI, // "rx/loki" RandomXL (Loki).
|
||||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||||
|
RX_SFX, // "rx/sfx" RandomSFX (Safex Cash).
|
||||||
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
||||||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
||||||
MAX
|
MAX
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -46,9 +46,6 @@ namespace xmrig {
|
||||||
static IMemoryPool *pool = nullptr;
|
static IMemoryPool *pool = nullptr;
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
constexpr size_t twoMiB = 2U * 1024U * 1024U;
|
|
||||||
constexpr size_t oneGiB = 1024U * 1024U * 1024U;
|
|
||||||
|
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
* Copyright 2018-2019 tevador <tevador@gmail.com>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
;# save VM register values
|
;# save VM register values
|
||||||
|
add rsp, 24
|
||||||
pop rcx
|
pop rcx
|
||||||
mov qword ptr [rcx+0], r8
|
mov qword ptr [rcx+0], r8
|
||||||
mov qword ptr [rcx+8], r9
|
mov qword ptr [rcx+8], r9
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
lea rcx, [rsi+rax]
|
lea rcx, [rsi+rax]
|
||||||
push rcx
|
mov [rsp+8], rcx
|
||||||
xor r8, qword ptr [rcx+0]
|
xor r8, qword ptr [rcx+0]
|
||||||
xor r9, qword ptr [rcx+8]
|
xor r9, qword ptr [rcx+8]
|
||||||
xor r10, qword ptr [rcx+16]
|
xor r10, qword ptr [rcx+16]
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
xor r14, qword ptr [rcx+48]
|
xor r14, qword ptr [rcx+48]
|
||||||
xor r15, qword ptr [rcx+56]
|
xor r15, qword ptr [rcx+56]
|
||||||
lea rcx, [rsi+rdx]
|
lea rcx, [rsi+rdx]
|
||||||
push rcx
|
mov [rsp+16], rcx
|
||||||
cvtdq2pd xmm0, qword ptr [rcx+0]
|
cvtdq2pd xmm0, qword ptr [rcx+0]
|
||||||
cvtdq2pd xmm1, qword ptr [rcx+8]
|
cvtdq2pd xmm1, qword ptr [rcx+8]
|
||||||
cvtdq2pd xmm2, qword ptr [rcx+16]
|
cvtdq2pd xmm2, qword ptr [rcx+16]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pop rcx
|
mov rcx, [rsp+16]
|
||||||
mov qword ptr [rcx+0], r8
|
mov qword ptr [rcx+0], r8
|
||||||
mov qword ptr [rcx+8], r9
|
mov qword ptr [rcx+8], r9
|
||||||
mov qword ptr [rcx+16], r10
|
mov qword ptr [rcx+16], r10
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
mov qword ptr [rcx+40], r13
|
mov qword ptr [rcx+40], r13
|
||||||
mov qword ptr [rcx+48], r14
|
mov qword ptr [rcx+48], r14
|
||||||
mov qword ptr [rcx+56], r15
|
mov qword ptr [rcx+56], r15
|
||||||
pop rcx
|
mov rcx, [rsp+8]
|
||||||
xorpd xmm0, xmm4
|
xorpd xmm0, xmm4
|
||||||
xorpd xmm1, xmm5
|
xorpd xmm1, xmm5
|
||||||
xorpd xmm2, xmm6
|
xorpd xmm2, xmm6
|
||||||
|
|
|
@ -36,6 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "crypto/randomx/program.hpp"
|
#include "crypto/randomx/program.hpp"
|
||||||
#include "crypto/randomx/reciprocal.h"
|
#include "crypto/randomx/reciprocal.h"
|
||||||
#include "crypto/randomx/virtual_memory.hpp"
|
#include "crypto/randomx/virtual_memory.hpp"
|
||||||
|
#include "crypto/rx/Rx.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
|
@ -168,8 +169,8 @@ namespace randomx {
|
||||||
static const uint8_t REX_MAXPD[] = { 0x66, 0x41, 0x0f, 0x5f };
|
static const uint8_t REX_MAXPD[] = { 0x66, 0x41, 0x0f, 0x5f };
|
||||||
static const uint8_t REX_DIVPD[] = { 0x66, 0x41, 0x0f, 0x5e };
|
static const uint8_t REX_DIVPD[] = { 0x66, 0x41, 0x0f, 0x5e };
|
||||||
static const uint8_t SQRTPD[] = { 0x66, 0x0f, 0x51 };
|
static const uint8_t SQRTPD[] = { 0x66, 0x0f, 0x51 };
|
||||||
static const uint8_t AND_OR_MOV_LDMXCSR[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x89, 0x44, 0x24, 0xFC, 0x0F, 0xAE, 0x54, 0x24, 0xFC };
|
static const uint8_t AND_OR_MOV_LDMXCSR[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x89, 0x04, 0x24, 0x0F, 0xAE, 0x14, 0x24 };
|
||||||
static const uint8_t AND_OR_MOV_LDMXCSR_RYZEN[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x3B, 0x44, 0x24, 0xFC, 0x74, 0x09, 0x89, 0x44, 0x24, 0xFC, 0x0F, 0xAE, 0x54, 0x24, 0xFC };
|
static const uint8_t AND_OR_MOV_LDMXCSR_RYZEN[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x3B, 0x04, 0x24, 0x74, 0x07, 0x89, 0x04, 0x24, 0x0F, 0xAE, 0x14, 0x24 };
|
||||||
static const uint8_t ROL_RAX[] = { 0x48, 0xc1, 0xc0 };
|
static const uint8_t ROL_RAX[] = { 0x48, 0xc1, 0xc0 };
|
||||||
static const uint8_t XOR_ECX_ECX[] = { 0x33, 0xC9 };
|
static const uint8_t XOR_ECX_ECX[] = { 0x33, 0xC9 };
|
||||||
static const uint8_t REX_CMP_R32I[] = { 0x41, 0x81 };
|
static const uint8_t REX_CMP_R32I[] = { 0x41, 0x81 };
|
||||||
|
@ -289,11 +290,20 @@ namespace randomx {
|
||||||
|
|
||||||
JitCompilerX86::JitCompilerX86() {
|
JitCompilerX86::JitCompilerX86() {
|
||||||
applyTweaks();
|
applyTweaks();
|
||||||
|
|
||||||
|
int32_t info[4];
|
||||||
|
cpuid(1, info);
|
||||||
|
hasAVX = ((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0);
|
||||||
|
|
||||||
allocatedCode = (uint8_t*)allocExecutableMemory(CodeSize * 2);
|
allocatedCode = (uint8_t*)allocExecutableMemory(CodeSize * 2);
|
||||||
// Shift code base address to improve caching - all threads will use different L2/L3 cache sets
|
// Shift code base address to improve caching - all threads will use different L2/L3 cache sets
|
||||||
code = allocatedCode + (codeOffset.fetch_add(59 * 64) % CodeSize);
|
code = allocatedCode + (codeOffset.fetch_add(59 * 64) % CodeSize);
|
||||||
memcpy(code, codePrologue, prologueSize);
|
memcpy(code, codePrologue, prologueSize);
|
||||||
memcpy(code + epilogueOffset, codeEpilogue, epilogueSize);
|
memcpy(code + epilogueOffset, codeEpilogue, epilogueSize);
|
||||||
|
# ifdef XMRIG_FIX_RYZEN
|
||||||
|
mainLoopBounds.first = code + prologueSize;
|
||||||
|
mainLoopBounds.second = code + epilogueOffset;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JitCompilerX86::~JitCompilerX86() {
|
JitCompilerX86::~JitCompilerX86() {
|
||||||
|
@ -374,6 +384,14 @@ namespace randomx {
|
||||||
code[codePos + 5] = 0xc0 + pcfg.readReg1;
|
code[codePos + 5] = 0xc0 + pcfg.readReg1;
|
||||||
*(uint32_t*)(code + codePos + 10) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
|
*(uint32_t*)(code + codePos + 10) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
|
||||||
*(uint32_t*)(code + codePos + 20) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
|
*(uint32_t*)(code + codePos + 20) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated;
|
||||||
|
if (hasAVX) {
|
||||||
|
uint32_t* p = (uint32_t*)(code + codePos + 32);
|
||||||
|
*p = (*p & 0xFF000000U) | 0x0077F8C5U;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_FIX_RYZEN
|
||||||
|
xmrig::Rx::setMainLoopBounds(mainLoopBounds);
|
||||||
|
# endif
|
||||||
|
|
||||||
codePos = prologueSize;
|
codePos = prologueSize;
|
||||||
memcpy(code + codePos - 48, &pcfg.eMask, sizeof(pcfg.eMask));
|
memcpy(code + codePos - 48, &pcfg.eMask, sizeof(pcfg.eMask));
|
||||||
|
@ -389,9 +407,10 @@ namespace randomx {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(RandomX_CurrentConfig.ProgramSize); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(RandomX_CurrentConfig.ProgramSize); i < n; ++i) {
|
||||||
Instruction instr = prog(i);
|
Instruction& instr = prog(i);
|
||||||
|
const uint8_t opcode = instr.opcode;
|
||||||
*((uint64_t*)&instr) &= (uint64_t(-1) - (0xFFFF << 8)) | ((RegistersCount - 1) << 8) | ((RegistersCount - 1) << 16);
|
*((uint64_t*)&instr) &= (uint64_t(-1) - (0xFFFF << 8)) | ((RegistersCount - 1) << 8) | ((RegistersCount - 1) << 16);
|
||||||
(this->*(engine[instr.opcode]))(instr);
|
(this->*(engine[opcode]))(instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(REX_MOV_RR, code, codePos);
|
emit(REX_MOV_RR, code, codePos);
|
||||||
|
@ -587,32 +606,22 @@ namespace randomx {
|
||||||
codePos = pos;
|
codePos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint32_t template_IADD_M[8] = {
|
|
||||||
0x0604034c,
|
|
||||||
0x060c034c,
|
|
||||||
0x0614034c,
|
|
||||||
0x061c034c,
|
|
||||||
0x0624034c,
|
|
||||||
0x062c034c,
|
|
||||||
0x0634034c,
|
|
||||||
0x063c034c,
|
|
||||||
};
|
|
||||||
|
|
||||||
void JitCompilerX86::h_IADD_M(const Instruction& instr) {
|
void JitCompilerX86::h_IADD_M(const Instruction& instr) {
|
||||||
uint8_t* const p = code;
|
uint8_t* const p = code;
|
||||||
int pos = codePos;
|
int pos = codePos;
|
||||||
|
|
||||||
if (instr.src != instr.dst) {
|
const uint32_t dst = instr.dst;
|
||||||
|
if (instr.src != dst) {
|
||||||
genAddressReg<true>(instr, p, pos);
|
genAddressReg<true>(instr, p, pos);
|
||||||
emit32(template_IADD_M[instr.dst], p, pos);
|
emit32(0x0604034c + (dst << 19), p, pos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit(REX_ADD_RM, p, pos);
|
emit(REX_ADD_RM, p, pos);
|
||||||
emitByte(0x86 + 8 * instr.dst, p, pos);
|
emitByte(0x86 + (dst << 3), p, pos);
|
||||||
genAddressImm(instr, p, pos);
|
genAddressImm(instr, p, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerUsage[instr.dst] = pos;
|
registerUsage[dst] = pos;
|
||||||
codePos = pos;
|
codePos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,19 +651,18 @@ namespace randomx {
|
||||||
uint8_t* const p = code;
|
uint8_t* const p = code;
|
||||||
int pos = codePos;
|
int pos = codePos;
|
||||||
|
|
||||||
if (instr.src != instr.dst) {
|
const uint32_t dst = instr.dst;
|
||||||
|
if (instr.src != dst) {
|
||||||
genAddressReg<true>(instr, p, pos);
|
genAddressReg<true>(instr, p, pos);
|
||||||
emit(REX_SUB_RM, p, pos);
|
emit32(0x06042b4c + (dst << 19), p, pos);
|
||||||
emitByte(0x04 + 8 * instr.dst, p, pos);
|
|
||||||
emitByte(0x06, p, pos);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit(REX_SUB_RM, p, pos);
|
emit(REX_SUB_RM, p, pos);
|
||||||
emitByte(0x86 + 8 * instr.dst, p, pos);
|
emitByte(0x86 + (dst << 3), p, pos);
|
||||||
genAddressImm(instr, p, pos);
|
genAddressImm(instr, p, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerUsage[instr.dst] = pos;
|
registerUsage[dst] = pos;
|
||||||
codePos = pos;
|
codePos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,14 +1050,12 @@ namespace randomx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(REX_ADD_I, p, pos);
|
*(uint32_t*)(p + pos) = 0x00c08149 + (reg << 16);
|
||||||
emitByte(0xc0 + reg, p, pos);
|
|
||||||
const int shift = instr.getModCond() + RandomX_CurrentConfig.JumpOffset;
|
const int shift = instr.getModCond() + RandomX_CurrentConfig.JumpOffset;
|
||||||
const uint32_t imm = (instr.getImm32() | (1UL << shift)) & ~(1UL << (shift - 1));
|
*(uint32_t*)(p + pos + 3) = (instr.getImm32() | (1UL << shift)) & ~(1UL << (shift - 1));
|
||||||
emit32(imm, p, pos);
|
*(uint32_t*)(p + pos + 7) = 0x00c0f749 + (reg << 16);
|
||||||
emit(REX_TEST, p, pos);
|
*(uint32_t*)(p + pos + 10) = RandomX_CurrentConfig.ConditionMask_Calculated << shift;
|
||||||
emitByte(0xc0 + reg, p, pos);
|
pos += 14;
|
||||||
emit32(RandomX_CurrentConfig.ConditionMask_Calculated << shift, p, pos);
|
|
||||||
|
|
||||||
if (jmp_offset >= -128) {
|
if (jmp_offset >= -128) {
|
||||||
emitByte(JZ_SHORT, p, pos);
|
emitByte(JZ_SHORT, p, pos);
|
||||||
|
@ -1076,9 +1082,7 @@ namespace randomx {
|
||||||
int pos = codePos;
|
int pos = codePos;
|
||||||
|
|
||||||
genAddressRegDst(instr, p, pos);
|
genAddressRegDst(instr, p, pos);
|
||||||
emit(REX_MOV_MR, p, pos);
|
emit32(0x0604894c + (static_cast<uint32_t>(instr.src) << 19), p, pos);
|
||||||
emitByte(0x04 + 8 * instr.src, p, pos);
|
|
||||||
emitByte(0x06, p, pos);
|
|
||||||
|
|
||||||
codePos = pos;
|
codePos = pos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,14 @@ namespace randomx {
|
||||||
int registerUsage[RegistersCount];
|
int registerUsage[RegistersCount];
|
||||||
uint8_t* allocatedCode;
|
uint8_t* allocatedCode;
|
||||||
uint8_t* code;
|
uint8_t* code;
|
||||||
|
# ifdef XMRIG_FIX_RYZEN
|
||||||
|
std::pair<const void*, const void*> mainLoopBounds;
|
||||||
|
# endif
|
||||||
int32_t codePos;
|
int32_t codePos;
|
||||||
uint32_t vm_flags;
|
uint32_t vm_flags;
|
||||||
|
|
||||||
static bool BranchesWithin32B;
|
static bool BranchesWithin32B;
|
||||||
|
bool hasAVX;
|
||||||
|
|
||||||
static void applyTweaks();
|
static void applyTweaks();
|
||||||
void generateProgramPrologue(Program&, ProgramConfiguration&);
|
void generateProgramPrologue(Program&, ProgramConfiguration&);
|
||||||
|
|
|
@ -93,7 +93,11 @@ DECL(randomx_program_prologue_first_load):
|
||||||
and eax, RANDOMX_SCRATCHPAD_MASK
|
and eax, RANDOMX_SCRATCHPAD_MASK
|
||||||
ror rdx, 32
|
ror rdx, 32
|
||||||
and edx, RANDOMX_SCRATCHPAD_MASK
|
and edx, RANDOMX_SCRATCHPAD_MASK
|
||||||
stmxcsr dword ptr [rsp-20]
|
sub rsp, 24
|
||||||
|
stmxcsr dword ptr [rsp]
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
jmp DECL(randomx_program_loop_begin)
|
jmp DECL(randomx_program_loop_begin)
|
||||||
|
|
||||||
.balign 64
|
.balign 64
|
||||||
|
|
|
@ -81,7 +81,11 @@ randomx_program_prologue_first_load PROC
|
||||||
and eax, RANDOMX_SCRATCHPAD_MASK
|
and eax, RANDOMX_SCRATCHPAD_MASK
|
||||||
ror rdx, 32
|
ror rdx, 32
|
||||||
and edx, RANDOMX_SCRATCHPAD_MASK
|
and edx, RANDOMX_SCRATCHPAD_MASK
|
||||||
stmxcsr dword ptr [rsp-20]
|
sub rsp, 24
|
||||||
|
stmxcsr dword ptr [rsp]
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
jmp randomx_program_loop_begin
|
jmp randomx_program_loop_begin
|
||||||
randomx_program_prologue_first_load ENDP
|
randomx_program_prologue_first_load ENDP
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,11 @@ RandomX_ConfigurationArqma::RandomX_ConfigurationArqma()
|
||||||
ScratchpadL3_Size = 262144;
|
ScratchpadL3_Size = 262144;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RandomX_ConfigurationSafex::RandomX_ConfigurationSafex()
|
||||||
|
{
|
||||||
|
ArgonSalt = "RandomSFX\x01";
|
||||||
|
}
|
||||||
|
|
||||||
RandomX_ConfigurationBase::RandomX_ConfigurationBase()
|
RandomX_ConfigurationBase::RandomX_ConfigurationBase()
|
||||||
: ArgonMemory(262144)
|
: ArgonMemory(262144)
|
||||||
, ArgonIterations(3)
|
, ArgonIterations(3)
|
||||||
|
@ -267,12 +272,17 @@ RandomX_ConfigurationMonero RandomX_MoneroConfig;
|
||||||
RandomX_ConfigurationWownero RandomX_WowneroConfig;
|
RandomX_ConfigurationWownero RandomX_WowneroConfig;
|
||||||
RandomX_ConfigurationLoki RandomX_LokiConfig;
|
RandomX_ConfigurationLoki RandomX_LokiConfig;
|
||||||
RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
||||||
|
RandomX_ConfigurationSafex RandomX_SafexConfig;
|
||||||
|
|
||||||
RandomX_ConfigurationBase RandomX_CurrentConfig;
|
RandomX_ConfigurationBase RandomX_CurrentConfig;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
|
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
|
||||||
|
if (!memory) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
randomx_cache *cache = nullptr;
|
randomx_cache *cache = nullptr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -317,6 +327,10 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
randomx_dataset *randomx_create_dataset(uint8_t *memory) {
|
randomx_dataset *randomx_create_dataset(uint8_t *memory) {
|
||||||
|
if (!memory) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto dataset = new randomx_dataset();
|
auto dataset = new randomx_dataset();
|
||||||
dataset->memory = memory;
|
dataset->memory = memory;
|
||||||
|
|
||||||
|
|
|
@ -182,11 +182,13 @@ struct RandomX_ConfigurationMonero : public RandomX_ConfigurationBase {};
|
||||||
struct RandomX_ConfigurationWownero : public RandomX_ConfigurationBase { RandomX_ConfigurationWownero(); };
|
struct RandomX_ConfigurationWownero : public RandomX_ConfigurationBase { RandomX_ConfigurationWownero(); };
|
||||||
struct RandomX_ConfigurationLoki : public RandomX_ConfigurationBase { RandomX_ConfigurationLoki(); };
|
struct RandomX_ConfigurationLoki : public RandomX_ConfigurationBase { RandomX_ConfigurationLoki(); };
|
||||||
struct RandomX_ConfigurationArqma : public RandomX_ConfigurationBase { RandomX_ConfigurationArqma(); };
|
struct RandomX_ConfigurationArqma : public RandomX_ConfigurationBase { RandomX_ConfigurationArqma(); };
|
||||||
|
struct RandomX_ConfigurationSafex : public RandomX_ConfigurationBase { RandomX_ConfigurationSafex(); };
|
||||||
|
|
||||||
extern RandomX_ConfigurationMonero RandomX_MoneroConfig;
|
extern RandomX_ConfigurationMonero RandomX_MoneroConfig;
|
||||||
extern RandomX_ConfigurationWownero RandomX_WowneroConfig;
|
extern RandomX_ConfigurationWownero RandomX_WowneroConfig;
|
||||||
extern RandomX_ConfigurationLoki RandomX_LokiConfig;
|
extern RandomX_ConfigurationLoki RandomX_LokiConfig;
|
||||||
extern RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
extern RandomX_ConfigurationArqma RandomX_ArqmaConfig;
|
||||||
|
extern RandomX_ConfigurationSafex RandomX_SafexConfig;
|
||||||
|
|
||||||
extern RandomX_ConfigurationBase RandomX_CurrentConfig;
|
extern RandomX_ConfigurationBase RandomX_CurrentConfig;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!osInitialized) {
|
if (!osInitialized) {
|
||||||
osInit(config);
|
msrInit(config);
|
||||||
|
setupMainLoopExceptionFrame();
|
||||||
osInitialized = true;
|
osInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +104,10 @@ xmrig::RxDataset *xmrig::Rx::dataset(const Job &job, uint32_t nodeId)
|
||||||
|
|
||||||
void xmrig::Rx::destroy()
|
void xmrig::Rx::destroy()
|
||||||
{
|
{
|
||||||
|
if (osInitialized) {
|
||||||
|
msrDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
|
|
||||||
d_ptr = nullptr;
|
d_ptr = nullptr;
|
||||||
|
@ -115,8 +120,20 @@ void xmrig::Rx::init(IRxListener *listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (!defined(XMRIG_OS_LINUX) && !defined(_WIN32)) || defined(XMRIG_ARM)
|
#ifndef XMRIG_FEATURE_MSR
|
||||||
void xmrig::Rx::osInit(const RxConfig &)
|
void xmrig::Rx::msrInit(const RxConfig &)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Rx::msrDestroy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XMRIG_FIX_RYZEN
|
||||||
|
void xmrig::Rx::setupMainLoopExceptionFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,8 +57,14 @@ public:
|
||||||
static void destroy();
|
static void destroy();
|
||||||
static void init(IRxListener *listener);
|
static void init(IRxListener *listener);
|
||||||
|
|
||||||
|
# ifdef XMRIG_FIX_RYZEN
|
||||||
|
static void setMainLoopBounds(const std::pair<const void*, const void*>& bounds);
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void osInit(const RxConfig &config);
|
static void msrInit(const RxConfig &config);
|
||||||
|
static void msrDestroy();
|
||||||
|
static void setupMainLoopExceptionFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ const RandomX_ConfigurationBase *xmrig::RxAlgo::base(Algorithm::Id algorithm)
|
||||||
case Algorithm::RX_ARQ:
|
case Algorithm::RX_ARQ:
|
||||||
return &RandomX_ArqmaConfig;
|
return &RandomX_ArqmaConfig;
|
||||||
|
|
||||||
|
case Algorithm::RX_SFX:
|
||||||
|
return &RandomX_SafexConfig;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,15 @@ public:
|
||||||
static uint32_t programIterations(Algorithm::Id algorithm);
|
static uint32_t programIterations(Algorithm::Id algorithm);
|
||||||
static uint32_t programSize(Algorithm::Id algorithm);
|
static uint32_t programSize(Algorithm::Id algorithm);
|
||||||
static uint32_t version(Algorithm::Id algorithm);
|
static uint32_t version(Algorithm::Id algorithm);
|
||||||
|
|
||||||
|
static inline Algorithm::Id id(Algorithm::Id algorithm)
|
||||||
|
{
|
||||||
|
if (algorithm == Algorithm::RX_SFX) {
|
||||||
|
return Algorithm::RX_0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return algorithm;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,11 @@ public:
|
||||||
XMRIG_DISABLE_COPY_MOVE(RxBasicStoragePrivate)
|
XMRIG_DISABLE_COPY_MOVE(RxBasicStoragePrivate)
|
||||||
|
|
||||||
inline RxBasicStoragePrivate() = default;
|
inline RxBasicStoragePrivate() = default;
|
||||||
inline ~RxBasicStoragePrivate()
|
inline ~RxBasicStoragePrivate() { deleteDataset(); }
|
||||||
{
|
|
||||||
delete m_dataset;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool isReady(const Job &job) const { return m_ready && m_seed == job; }
|
inline bool isReady(const Job &job) const { return m_ready && m_seed == job; }
|
||||||
inline RxDataset *dataset() const { return m_dataset; }
|
inline RxDataset *dataset() const { return m_dataset; }
|
||||||
|
inline void deleteDataset() { delete m_dataset; m_dataset = nullptr; }
|
||||||
|
|
||||||
|
|
||||||
inline void setSeed(const RxSeed &seed)
|
inline void setSeed(const RxSeed &seed)
|
||||||
|
@ -69,12 +67,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void createDataset(bool hugePages, bool oneGbPages, RxConfig::Mode mode)
|
inline bool createDataset(bool hugePages, bool oneGbPages, RxConfig::Mode mode)
|
||||||
{
|
{
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
m_dataset = new RxDataset(hugePages, oneGbPages, true, mode, 0);
|
m_dataset = new RxDataset(hugePages, oneGbPages, true, mode, 0);
|
||||||
|
if (!m_dataset->cache()->get()) {
|
||||||
|
deleteDataset();
|
||||||
|
|
||||||
|
LOG_INFO("%s" RED_BOLD("failed to allocate RandomX memory") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
printAllocStatus(ts);
|
printAllocStatus(ts);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,11 +90,11 @@ public:
|
||||||
{
|
{
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
m_dataset->init(m_seed.data(), threads, priority);
|
m_ready = m_dataset->init(m_seed.data(), threads, priority);
|
||||||
|
|
||||||
|
if (m_ready) {
|
||||||
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||||
|
}
|
||||||
m_ready = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,6 +144,12 @@ xmrig::RxBasicStorage::~RxBasicStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::RxBasicStorage::isAllocated() const
|
||||||
|
{
|
||||||
|
return d_ptr->dataset() && d_ptr->dataset()->cache() && d_ptr->dataset()->cache()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::HugePagesInfo xmrig::RxBasicStorage::hugePages() const
|
xmrig::HugePagesInfo xmrig::RxBasicStorage::hugePages() const
|
||||||
{
|
{
|
||||||
if (!d_ptr->dataset()) {
|
if (!d_ptr->dataset()) {
|
||||||
|
@ -160,8 +174,8 @@ void xmrig::RxBasicStorage::init(const RxSeed &seed, uint32_t threads, bool huge
|
||||||
{
|
{
|
||||||
d_ptr->setSeed(seed);
|
d_ptr->setSeed(seed);
|
||||||
|
|
||||||
if (!d_ptr->dataset()) {
|
if (!d_ptr->dataset() && !d_ptr->createDataset(hugePages, oneGbPages, mode)) {
|
||||||
d_ptr->createDataset(hugePages, oneGbPages, mode);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->initDataset(threads, priority);
|
d_ptr->initDataset(threads, priority);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
~RxBasicStorage() override;
|
~RxBasicStorage() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool isAllocated() const override;
|
||||||
HugePagesInfo hugePages() const override;
|
HugePagesInfo hugePages() const override;
|
||||||
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
||||||
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) override;
|
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) override;
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
|
|
||||||
static_assert(RANDOMX_FLAG_JIT == 8, "RANDOMX_FLAG_JIT flag mismatch");
|
static_assert(RANDOMX_FLAG_JIT == 8, "RANDOMX_FLAG_JIT flag mismatch");
|
||||||
static_assert(RANDOMX_FLAG_LARGE_PAGES == 1, "RANDOMX_FLAG_LARGE_PAGES flag mismatch");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xmrig::RxCache::RxCache(bool hugePages, uint32_t nodeId)
|
xmrig::RxCache::RxCache(bool hugePages, uint32_t nodeId)
|
||||||
|
@ -64,11 +62,16 @@ bool xmrig::RxCache::init(const Buffer &seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_seed = seed;
|
m_seed = seed;
|
||||||
|
|
||||||
|
if (m_cache) {
|
||||||
randomx_init_cache(m_cache, m_seed.data(), m_seed.size());
|
randomx_init_cache(m_cache, m_seed.data(), m_seed.size());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::HugePagesInfo xmrig::RxCache::hugePages() const
|
xmrig::HugePagesInfo xmrig::RxCache::hugePages() const
|
||||||
{
|
{
|
||||||
|
@ -78,6 +81,10 @@ xmrig::HugePagesInfo xmrig::RxCache::hugePages() const
|
||||||
|
|
||||||
void xmrig::RxCache::create(uint8_t *memory)
|
void xmrig::RxCache::create(uint8_t *memory)
|
||||||
{
|
{
|
||||||
|
if (!memory) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_cache = randomx_create_cache(RANDOMX_FLAG_JIT, memory);
|
m_cache = randomx_create_cache(RANDOMX_FLAG_JIT, memory);
|
||||||
|
|
||||||
if (!m_cache) {
|
if (!m_cache) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ namespace xmrig {
|
||||||
static const char *kInit = "init";
|
static const char *kInit = "init";
|
||||||
static const char *kMode = "mode";
|
static const char *kMode = "mode";
|
||||||
static const char *kOneGbPages = "1gb-pages";
|
static const char *kOneGbPages = "1gb-pages";
|
||||||
|
static const char *kRdmsr = "rdmsr";
|
||||||
static const char *kWrmsr = "wrmsr";
|
static const char *kWrmsr = "wrmsr";
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HWLOC
|
#ifdef XMRIG_FEATURE_HWLOC
|
||||||
|
@ -57,6 +58,23 @@ static const char *kNUMA = "numa";
|
||||||
|
|
||||||
static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "fast", "light" };
|
static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "fast", "light" };
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
|
constexpr size_t kMsrArraySize = 4;
|
||||||
|
|
||||||
|
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
||||||
|
MsrItems(),
|
||||||
|
MsrItems{{ 0xC0011020, 0x0 }, { 0xC0011021, 0x40, ~0x20ULL }, { 0xC0011022, 0x510000 }, { 0xC001102b, 0x1808cc16 }},
|
||||||
|
MsrItems{{ 0x1a4, 0xf }},
|
||||||
|
MsrItems()
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::array<const char *, kMsrArraySize> modNames = { "none", "ryzen", "intel", "custom" };
|
||||||
|
|
||||||
|
static_assert (kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +83,11 @@ bool xmrig::RxConfig::read(const rapidjson::Value &value)
|
||||||
if (value.IsObject()) {
|
if (value.IsObject()) {
|
||||||
m_threads = Json::getInt(value, kInit, m_threads);
|
m_threads = Json::getInt(value, kInit, m_threads);
|
||||||
m_mode = readMode(Json::getValue(value, kMode));
|
m_mode = readMode(Json::getValue(value, kMode));
|
||||||
m_wrmsr = readMSR(Json::getValue(value, kWrmsr));
|
m_rdmsr = Json::getBool(value, kRdmsr, m_rdmsr);
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_MSR
|
||||||
|
readMSR(Json::getValue(value, kWrmsr));
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_OS_LINUX
|
# ifdef XMRIG_OS_LINUX
|
||||||
m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages);
|
m_oneGbPages = Json::getBool(value, kOneGbPages, m_oneGbPages);
|
||||||
|
@ -109,13 +131,25 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const
|
||||||
obj.AddMember(StringRef(kInit), m_threads, allocator);
|
obj.AddMember(StringRef(kInit), m_threads, allocator);
|
||||||
obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator);
|
obj.AddMember(StringRef(kMode), StringRef(modeName()), allocator);
|
||||||
obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator);
|
obj.AddMember(StringRef(kOneGbPages), m_oneGbPages, allocator);
|
||||||
|
obj.AddMember(StringRef(kRdmsr), m_rdmsr, allocator);
|
||||||
|
|
||||||
if (m_wrmsr < 0 || m_wrmsr == 6) {
|
# ifdef XMRIG_FEATURE_MSR
|
||||||
obj.AddMember(StringRef(kWrmsr), m_wrmsr == 6, allocator);
|
if (!m_msrPreset.empty()) {
|
||||||
|
Value wrmsr(kArrayType);
|
||||||
|
wrmsr.Reserve(m_msrPreset.size(), allocator);
|
||||||
|
|
||||||
|
for (const auto &i : m_msrPreset) {
|
||||||
|
wrmsr.PushBack(i.toJSON(doc), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.AddMember(StringRef(kWrmsr), wrmsr, allocator);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj.AddMember(StringRef(kWrmsr), m_wrmsr, allocator);
|
obj.AddMember(StringRef(kWrmsr), m_wrmsr, allocator);
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
obj.AddMember(StringRef(kWrmsr), false, allocator);
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HWLOC
|
# ifdef XMRIG_FEATURE_HWLOC
|
||||||
if (!m_nodeset.empty()) {
|
if (!m_nodeset.empty()) {
|
||||||
|
@ -168,20 +202,71 @@ uint32_t xmrig::RxConfig::threads(uint32_t limit) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int xmrig::RxConfig::readMSR(const rapidjson::Value &value) const
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
|
const char *xmrig::RxConfig::msrPresetName() const
|
||||||
{
|
{
|
||||||
if (value.IsInt()) {
|
return modNames[msrMod()];
|
||||||
return std::min(value.GetInt(), 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.IsBool() && !value.GetBool()) {
|
|
||||||
return -1;
|
const xmrig::MsrItems &xmrig::RxConfig::msrPreset() const
|
||||||
|
{
|
||||||
|
const auto mod = msrMod();
|
||||||
|
|
||||||
|
if (mod == ICpuInfo::MSR_MOD_CUSTOM) {
|
||||||
|
return m_msrPreset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_wrmsr;
|
return msrPresets[mod];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::RxConfig::msrMod() const
|
||||||
|
{
|
||||||
|
if (!wrmsr()) {
|
||||||
|
return ICpuInfo::MSR_MOD_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_msrPreset.empty()) {
|
||||||
|
return ICpuInfo::MSR_MOD_CUSTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Cpu::info()->msrMod();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::RxConfig::readMSR(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (value.IsBool()) {
|
||||||
|
m_wrmsr = value.GetBool();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.IsInt() && Cpu::info()->vendor() == ICpuInfo::VENDOR_INTEL) {
|
||||||
|
const int i = std::min(value.GetInt(), 15);
|
||||||
|
if (i >= 0) {
|
||||||
|
m_msrPreset.emplace_back(0x1a4, i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_wrmsr = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.IsArray()) {
|
||||||
|
for (const auto &i : value.GetArray()) {
|
||||||
|
MsrItem item(i);
|
||||||
|
if (item.isValid()) {
|
||||||
|
m_msrPreset.emplace_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_wrmsr = !m_msrPreset.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
xmrig::RxConfig::Mode xmrig::RxConfig::readMode(const rapidjson::Value &value) const
|
xmrig::RxConfig::Mode xmrig::RxConfig::readMode(const rapidjson::Value &value) const
|
||||||
{
|
{
|
||||||
if (value.IsUint()) {
|
if (value.IsUint()) {
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
|
# include "crypto/rx/msr/MsrItem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,17 +63,32 @@ public:
|
||||||
uint32_t threads(uint32_t limit = 100) const;
|
uint32_t threads(uint32_t limit = 100) const;
|
||||||
|
|
||||||
inline bool isOneGbPages() const { return m_oneGbPages; }
|
inline bool isOneGbPages() const { return m_oneGbPages; }
|
||||||
inline int wrmsr() const { return m_wrmsr; }
|
inline bool rdmsr() const { return m_rdmsr; }
|
||||||
|
inline bool wrmsr() const { return m_wrmsr; }
|
||||||
inline Mode mode() const { return m_mode; }
|
inline Mode mode() const { return m_mode; }
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_MSR
|
||||||
|
const char *msrPresetName() const;
|
||||||
|
const MsrItems &msrPreset() const;
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int readMSR(const rapidjson::Value &value) const;
|
# ifdef XMRIG_FEATURE_MSR
|
||||||
|
uint32_t msrMod() const;
|
||||||
|
void readMSR(const rapidjson::Value &value);
|
||||||
|
|
||||||
|
bool m_wrmsr = true;
|
||||||
|
MsrItems m_msrPreset;
|
||||||
|
# else
|
||||||
|
bool m_wrmsr = false;
|
||||||
|
# endif
|
||||||
|
|
||||||
Mode readMode(const rapidjson::Value &value) const;
|
Mode readMode(const rapidjson::Value &value) const;
|
||||||
|
|
||||||
bool m_numa = true;
|
bool m_numa = true;
|
||||||
bool m_oneGbPages = false;
|
bool m_oneGbPages = false;
|
||||||
|
bool m_rdmsr = true;
|
||||||
int m_threads = -1;
|
int m_threads = -1;
|
||||||
int m_wrmsr = 6;
|
|
||||||
Mode m_mode = AutoMode;
|
Mode m_mode = AutoMode;
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HWLOC
|
# ifdef XMRIG_FEATURE_HWLOC
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue