1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-07 07:55:04 -05:00

Compare commits

...

59 Commits

Author SHA1 Message Date
xmrig
c2d662ff4c Update CHANGELOG.md 2019-06-25 14:48:43 +07:00
XMRig
6813657891 v2.16.0-beta 2019-06-25 14:17:43 +07:00
XMRig
ee93095e06 Merge branch 'evo' into beta 2019-06-25 14:17:06 +07:00
XMRig
b0a1481909 Sync changes with proxy. 2019-06-25 10:35:10 +07:00
XMRig
f7f2c09e89 Move RandowWOW to new global algorithm. 2019-06-25 08:21:40 +07:00
XMRig
cf61f49746 Use better source for AES settings in RandomX threads. 2019-06-23 14:23:29 +07:00
xmrig
1a2f9fb160 Merge pull request #1039 from SChernykh/random_wow
Fixed RandomX for CPUs without AES
2019-06-22 17:15:49 +07:00
SChernykh
187e55e28e Fixed RandomX for CPUs without AES 2019-06-19 12:45:05 +02:00
XMRig
41e0be111d v2.16.0-evo, added RandomWOW, backward compatibility with previous versions not break. 2019-06-19 01:18:31 +07:00
XMRig
e743301a79 Merge branch 'feature-randomx' into evo 2019-06-19 01:16:51 +07:00
xmrig
7a6c7aac29 Merge pull request #1037 from SChernykh/random_wow
RandomX fixes
2019-06-19 01:06:43 +07:00
SChernykh
53c9e5fe0e Merge remote-tracking branch 'upstream/feature-randomx' into random_wow 2019-06-18 19:53:26 +02:00
SChernykh
e8ac01d289 RandomX fixes
- Fixed possible infinite loop when updating RandomX dataset
- Fixed used memory display
- Allocate dataset and VM for RandomX only when it's actually used
2019-06-18 19:53:11 +02:00
XMRig
2a07cf391d Allow disable RandomX support. 2019-06-18 06:11:53 +07:00
XMRig
3d17ba6af6 Merge branch 'feature-randomx' into evo 2019-06-18 05:33:30 +07:00
XMRig
34e39e9946 Use canonical name for RandomX, because official RandomWOW repo not rename lib or headers, still need some solution to separate it in future. 2019-06-18 05:13:51 +07:00
xmrig
2b26874f11 Merge pull request #1036 from SChernykh/random_wow
RandomWOW
2019-06-18 03:49:18 +07:00
SChernykh
50ace41766 Fixed cmake for Linux 2019-06-15 23:52:39 +02:00
SChernykh
d0ce60a73a Fixed auto-config 2019-06-15 23:50:31 +02:00
SChernykh
202d44c147 Fixed gcc compilation 2019-06-15 23:29:13 +02:00
SChernykh
ac1b554282 RandomWOW support 2019-06-15 22:53:03 +02:00
XMRig
725c767928 v2.99.0-evo 2019-06-09 16:48:30 +07:00
XMRig
b684150336 Moved Algorithm class. 2019-06-09 16:46:44 +07:00
XMRig
d9eb700e03 Renamed macros for enable/disable algorithms. 2019-06-09 15:29:26 +07:00
XMRig
09cdddc7f6 Fixed ARM build, again. 2019-06-04 19:49:54 +07:00
XMRig
bd8370951f Fixed ARM build. 2019-06-04 19:27:51 +07:00
XMRig
d587eebaf2 Move files. 2019-06-04 19:20:33 +07:00
XMRig
ac43cd4f9c Added unprotectExecutableMemory for future use. 2019-06-04 15:48:32 +07:00
XMRig
f620ffe899 #1026 Probably fixed iOS build. 2019-06-03 18:40:12 +07:00
XMRig
242ece7222 Simplified cn/r code. 2019-06-02 23:38:02 +07:00
XMRig
36fcdf3f9d Fixed ARM build. 2019-06-02 21:06:30 +07:00
XMRig
ba94c08bf5 Moved mm_malloc.h 2019-06-02 20:57:49 +07:00
XMRig
8dc586283f Fixed Linux build. 2019-06-02 19:58:16 +07:00
XMRig
fc655d1b8d Moved common memory primitives to new VirtualMemory class. 2019-06-02 19:43:56 +07:00
XMRig
4b3592f60f v2.15.5-evo 2019-06-02 15:03:26 +07:00
XMRig
cd32677ad4 Merge branch 'beta' into evo 2019-06-02 15:02:19 +07:00
XMRig
277f188cd5 v2.15.4-beta 2019-06-02 14:30:09 +07:00
XMRig
e28c3db019 Merge branch 'evo' into beta 2019-06-02 14:29:39 +07:00
xmrig
5dde5dbf4e Update CHANGELOG.md 2019-06-02 14:18:13 +07:00
xmrig
9726f8cf9d Update CHANGELOG.md 2019-06-02 14:16:45 +07:00
XMRig
833a532e7a Merge branch 'dev' into evo 2019-05-31 23:20:35 +07:00
XMRig
3dde8cacff v2.14.5-dev 2019-05-31 22:50:39 +07:00
XMRig
84b359f29c Merge branch 'master' into dev 2019-05-31 22:50:13 +07:00
XMRig
2d8e8c92ab v2.14.4 2019-05-30 12:16:19 +07:00
XMRig
651009e1b9 Merge branch 'dev' 2019-05-30 12:11:47 +07:00
XMRig
1d4bc030fb v2.14.4-dev 2019-05-26 19:28:28 +07:00
xmrig
809efb4700 Update CHANGELOG.md 2019-05-26 19:21:13 +07:00
XMRig
10165da53e Removed obsolete automatic variants. 2019-05-26 18:54:47 +07:00
XMRig
51b92f66cf Sync changes. 2019-05-25 10:58:35 +07:00
XMRig
6fb014d0b1 Fixed MSVC 2019 version detection. 2019-05-21 12:14:20 +07:00
XMRig
ffb282a11a Added global uptime and extended connection information for API. 2019-05-13 00:11:57 +07:00
XMRig
a000544fdc Return current algorithm in API response. 2019-05-01 22:07:13 +07:00
XMRig
378bc504fc Use null for unknown hashrate in API. 2019-04-25 02:22:53 +07:00
XMRig
304d7bd09a v2.15.4-evo 2019-04-18 20:59:14 +07:00
XMRig
e9e2d7d152 Merge branch 'beta' into evo 2019-04-18 20:58:32 +07:00
XMRig
8b0d35b619 #1014 Fixed regression, default value for algo option was not applied. 2019-04-18 15:23:36 +07:00
xmrig
356fd04b0f Update README.md 2019-04-01 18:55:30 +07:00
xmrig
5a4720cf4a Merge pull request #1008 from snider/master
updates image used in readme for new pool url
2019-04-01 18:55:06 +07:00
snider
c0e2a15614 updates image used in readme for new pool url 2019-04-01 12:16:36 +01:00
108 changed files with 796 additions and 329 deletions

View File

@@ -1,3 +1,16 @@
# v2.16.0-beta
- Added RandomWOW (RandomX with different preferences) algorithm support for [Wownero](http://wownero.org/).
- Algorithm name used by miner is `randomx/wow` or `rx/wow`.
- Currently runtime algorithm switching NOT supported with other algorithms.
# v2.15.4-beta
- Added global uptime and extended connection information in API.
- API now return current algorithm instead of global algorithm specified in config.
- This version also include all changes from stable version v2.14.4.
# v2.15.3-beta
- [#1014](https://github.com/xmrig/xmrig/issues/1014) Fixed regression, default value for `algo` option was not applied.
# v2.15.2-beta # v2.15.2-beta
- [#1010](https://github.com/xmrig/xmrig/pull/1010#issuecomment-482632107) Added daemon support (solo mining). - [#1010](https://github.com/xmrig/xmrig/pull/1010#issuecomment-482632107) Added daemon support (solo mining).
- [#1012](https://github.com/xmrig/xmrig/pull/1012) Fixed compatibility with clang 9. - [#1012](https://github.com/xmrig/xmrig/pull/1012) Fixed compatibility with clang 9.
@@ -13,6 +26,13 @@
- Added new option `donate-over-proxy`. - Added new option `donate-over-proxy`.
- Added real graceful exit. - Added real graceful exit.
# v2.14.4
- [#992](https://github.com/xmrig/xmrig/pull/992) Fixed compilation with Clang 3.5.
- [#1012](https://github.com/xmrig/xmrig/pull/1012) Fixed compilation with Clang 9.0.
- In HTTP API for unknown hashrate now used `null` instead of `0.0`.
- Fixed MSVC 2019 version detection.
- Removed obsolete automatic variants.
# v2.14.1 # v2.14.1
* [#975](https://github.com/xmrig/xmrig/issues/975) Fixed crash on Linux if double thread mode used. * [#975](https://github.com/xmrig/xmrig/issues/975) Fixed crash on Linux if double thread mode used.

View File

@@ -2,10 +2,11 @@ cmake_minimum_required(VERSION 2.8)
project(xmrig) project(xmrig)
option(WITH_LIBCPUID "Use Libcpuid" ON) option(WITH_LIBCPUID "Use Libcpuid" ON)
option(WITH_AEON "CryptoNight-Lite support" ON) option(WITH_CN_LITE "CryptoNight-Lite support" ON)
option(WITH_SUMO "CryptoNight-Heavy support" ON) option(WITH_CN_HEAVY "CryptoNight-Heavy support" ON)
option(WITH_CN_PICO "CryptoNight-Pico support" ON) option(WITH_CN_PICO "CryptoNight-Pico support" ON)
option(WITH_CN_GPU "CryptoNight-GPU support" ON) option(WITH_CN_GPU "CryptoNight-GPU support" ON)
option(WITH_RANDOMX "RandomX support" ON)
option(WITH_HTTP "HTTP protocol support (client/server)" ON) option(WITH_HTTP "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)
@@ -25,11 +26,9 @@ set(HEADERS
src/api/interfaces/IApiListener.h src/api/interfaces/IApiListener.h
src/App.h src/App.h
src/common/cpu/Cpu.h src/common/cpu/Cpu.h
src/common/crypto/Algorithm.h
src/common/crypto/keccak.h src/common/crypto/keccak.h
src/common/interfaces/ICpuInfo.h src/common/interfaces/ICpuInfo.h
src/common/Platform.h src/common/Platform.h
src/common/utils/mm_malloc.h
src/common/xmrig.h src/common/xmrig.h
src/core/config/Config_default.h src/core/config/Config_default.h
src/core/config/Config_platform.h src/core/config/Config_platform.h
@@ -56,32 +55,34 @@ set(HEADERS
) )
set(HEADERS_CRYPTO set(HEADERS_CRYPTO
src/crypto/c_blake256.h src/crypto/cn/asm/CryptonightR_template.h
src/crypto/c_groestl.h src/crypto/cn/c_blake256.h
src/crypto/c_jh.h src/crypto/cn/c_groestl.h
src/crypto/c_skein.h src/crypto/cn/c_jh.h
src/crypto/CryptoNight.h src/crypto/cn/c_skein.h
src/crypto/CryptoNight_constants.h src/crypto/cn/CryptoNight_constants.h
src/crypto/CryptoNight_monero.h src/crypto/cn/CryptoNight_monero.h
src/crypto/CryptoNight_test.h src/crypto/cn/CryptoNight_test.h
src/crypto/groestl_tables.h src/crypto/cn/CryptoNight.h
src/crypto/hash.h src/crypto/cn/groestl_tables.h
src/crypto/skein_port.h src/crypto/cn/hash.h
src/crypto/soft_aes.h src/crypto/cn/skein_port.h
src/crypto/asm/CryptonightR_template.h src/crypto/cn/soft_aes.h
src/crypto/common/Algorithm.h
src/crypto/common/portable/mm_malloc.h
src/crypto/common/VirtualMemory.h
) )
if (XMRIG_ARM) if (XMRIG_ARM)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/CryptoNight_arm.h) set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_arm.h)
else() else()
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/CryptoNight_x86.h) set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86.h)
endif() endif()
set(SOURCES set(SOURCES
"${SOURCES_BASE}" "${SOURCES_BASE}"
"${SOURCES_BASE_HTTP}" "${SOURCES_BASE_HTTP}"
src/App.cpp src/App.cpp
src/common/crypto/Algorithm.cpp
src/common/crypto/keccak.cpp src/common/crypto/keccak.cpp
src/common/Platform.cpp src/common/Platform.cpp
src/core/config/Config.cpp src/core/config/Config.cpp
@@ -102,10 +103,11 @@ set(SOURCES
) )
set(SOURCES_CRYPTO set(SOURCES_CRYPTO
src/crypto/c_groestl.c src/crypto/cn/c_groestl.c
src/crypto/c_blake256.c src/crypto/cn/c_blake256.c
src/crypto/c_jh.c src/crypto/cn/c_jh.c
src/crypto/c_skein.c src/crypto/cn/c_skein.c
src/crypto/common/Algorithm.cpp
) )
if (WIN32) if (WIN32)
@@ -115,6 +117,7 @@ if (WIN32)
src/App_win.cpp src/App_win.cpp
src/common/Platform_win.cpp src/common/Platform_win.cpp
src/Mem_win.cpp src/Mem_win.cpp
src/crypto/common/VirtualMemory_win.cpp
) )
add_definitions(/DWIN32) add_definitions(/DWIN32)
@@ -125,6 +128,7 @@ elseif (APPLE)
src/App_unix.cpp src/App_unix.cpp
src/common/Platform_mac.cpp src/common/Platform_mac.cpp
src/Mem_unix.cpp src/Mem_unix.cpp
src/crypto/common/VirtualMemory_unix.cpp
) )
else() else()
set(SOURCES_OS set(SOURCES_OS
@@ -132,6 +136,7 @@ else()
src/App_unix.cpp src/App_unix.cpp
src/common/Platform_unix.cpp src/common/Platform_unix.cpp
src/Mem_unix.cpp src/Mem_unix.cpp
src/crypto/common/VirtualMemory_unix.cpp
) )
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
@@ -155,6 +160,17 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
find_package(UV REQUIRED) find_package(UV REQUIRED)
if (WITH_RANDOMX)
find_package(RandomX REQUIRED)
include_directories(${RANDOMX_INCLUDE_DIR})
add_definitions(/DXMRIG_ALGO_RANDOMX)
else()
set(RANDOMX_LIBRARIES "")
remove_definitions(/DXMRIG_ALGO_RANDOMX)
endif()
include(cmake/flags.cmake) include(cmake/flags.cmake)
if (WITH_LIBCPUID) if (WITH_LIBCPUID)
@@ -178,20 +194,16 @@ include(cmake/OpenSSL.cmake)
include(cmake/asm.cmake) include(cmake/asm.cmake)
include(cmake/cn-gpu.cmake) include(cmake/cn-gpu.cmake)
if (NOT WITH_AEON) if (WITH_CN_LITE)
add_definitions(/DXMRIG_NO_AEON) add_definitions(/DXMRIG_ALGO_CN_LITE)
endif() endif()
if (NOT WITH_SUMO) if (WITH_CN_HEAVY)
add_definitions(/DXMRIG_NO_SUMO) add_definitions(/DXMRIG_ALGO_CN_HEAVY)
endif() endif()
if (NOT WITH_IPBC) if (WITH_CN_PICO)
add_definitions(/DXMRIG_NO_IPBC) add_definitions(/DXMRIG_ALGO_CN_PICO)
endif()
if (NOT WITH_CN_PICO)
add_definitions(/DXMRIG_NO_CN_PICO)
endif() endif()
if (WITH_EMBEDDED_CONFIG) if (WITH_EMBEDDED_CONFIG)
@@ -229,4 +241,4 @@ if (WITH_DEBUG_LOG)
endif() endif()
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTP_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES} ${CN_GPU_SOURCES}) add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTP_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES} ${CN_GPU_SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB}) target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${RANDOMX_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB})

View File

@@ -13,7 +13,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin
* This is the **CPU-mining** version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia) and [AMD GPU version]( https://github.com/xmrig/xmrig-amd). * This is the **CPU-mining** version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia) and [AMD GPU version]( https://github.com/xmrig/xmrig-amd).
* [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases. * [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases.
<img src="http://i.imgur.com/OKZRVDh.png" width="619" > <img src="http://i.imgur.com/Ymumes5.png" width="670" >
#### Table of contents #### Table of contents
* [Features](#features) * [Features](#features)

25
cmake/FindRandomX.cmake Normal file
View File

@@ -0,0 +1,25 @@
find_path(
RANDOMX_INCLUDE_DIR
NAMES randomx.h
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
find_path(RANDOMX_INCLUDE_DIR NAMES randomx.h)
find_library(
RANDOMX_LIBRARY
NAMES librandomx.a randomx librandomx
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
find_library(RANDOMX_LIBRARY NAMES librandomx.a randomx librandomx)
set(RANDOMX_LIBRARIES ${RANDOMX_LIBRARY})
set(RANDOMX_INCLUDE_DIRS ${RANDOMX_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RANDOMX DEFAULT_MSG RANDOMX_LIBRARY RANDOMX_INCLUDE_DIR)

View File

@@ -6,13 +6,13 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
if (MSVC_TOOLSET_VERSION GREATER_EQUAL 141) if (MSVC_TOOLSET_VERSION GREATER_EQUAL 141)
set(XMRIG_ASM_FILES set(XMRIG_ASM_FILES
"src/crypto/asm/cn_main_loop.asm" "src/crypto/cn/asm/cn_main_loop.asm"
"src/crypto/asm/CryptonightR_template.asm" "src/crypto/cn/asm/CryptonightR_template.asm"
) )
else() else()
set(XMRIG_ASM_FILES set(XMRIG_ASM_FILES
"src/crypto/asm/win64/cn_main_loop.asm" "src/crypto/cn/asm/win64/cn_main_loop.asm"
"src/crypto/asm/win64/CryptonightR_template.asm" "src/crypto/cn/asm/win64/CryptonightR_template.asm"
) )
endif() endif()
@@ -22,13 +22,13 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
if (WIN32 AND CMAKE_C_COMPILER_ID MATCHES GNU) if (WIN32 AND CMAKE_C_COMPILER_ID MATCHES GNU)
set(XMRIG_ASM_FILES set(XMRIG_ASM_FILES
"src/crypto/asm/win64/cn_main_loop.S" "src/crypto/cn/asm/win64/cn_main_loop.S"
"src/crypto/asm/CryptonightR_template.S" "src/crypto/cn/asm/CryptonightR_template.S"
) )
else() else()
set(XMRIG_ASM_FILES set(XMRIG_ASM_FILES
"src/crypto/asm/cn_main_loop.S" "src/crypto/cn/asm/cn_main_loop.S"
"src/crypto/asm/CryptonightR_template.S" "src/crypto/cn/asm/CryptonightR_template.S"
) )
endif() endif()
@@ -36,7 +36,7 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
endif() endif()
add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES}) add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES})
set(XMRIG_ASM_SOURCES src/crypto/Asm.h src/crypto/Asm.cpp src/crypto/CryptonightR_gen.cpp) set(XMRIG_ASM_SOURCES src/crypto/cn/Asm.h src/crypto/cn/Asm.cpp src/crypto/cn/r/CryptonightR_gen.cpp)
set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C) set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C)
else() else()
set(XMRIG_ASM_SOURCES "") set(XMRIG_ASM_SOURCES "")

View File

@@ -1,23 +1,25 @@
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8) if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
if (XMRIG_ARM) if (XMRIG_ARM)
set(CN_GPU_SOURCES src/crypto/cn_gpu_arm.cpp) set(CN_GPU_SOURCES src/crypto/cn/gpu/cn_gpu_arm.cpp)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(src/crypto/cn_gpu_arm.cpp PROPERTIES COMPILE_FLAGS "-O3") set_source_files_properties(src/crypto/cn/gpu/cn_gpu_arm.cpp PROPERTIES COMPILE_FLAGS "-O3")
endif() endif()
else() else()
set(CN_GPU_SOURCES src/crypto/cn_gpu_avx.cpp src/crypto/cn_gpu_ssse3.cpp) set(CN_GPU_SOURCES src/crypto/cn/gpu/cn_gpu_avx.cpp src/crypto/cn/gpu/cn_gpu_ssse3.cpp)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
set_source_files_properties(src/crypto/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O3 -mavx2") set_source_files_properties(src/crypto/cn/gpu/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O3 -mavx2")
set_source_files_properties(src/crypto/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O3") set_source_files_properties(src/crypto/cn/gpu/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O3")
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
set_source_files_properties(src/crypto/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX") set_source_files_properties(src/crypto/cn/gpu/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
endif() endif()
endif() endif()
add_definitions(/DXMRIG_ALGO_CN_GPU)
else() else()
set(CN_GPU_SOURCES "") set(CN_GPU_SOURCES "")
add_definitions(/DXMRIG_NO_CN_GPU) remove_definitions(/DXMRIG_ALGO_CN_GPU)
endif() endif()

View File

@@ -81,3 +81,10 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
endif() endif()
endif() endif()
if (NOT WIN32)
check_symbol_exists("__builtin___clear_cache" "stdlib.h" HAVE_BUILTIN_CLEAR_CACHE)
if (HAVE_BUILTIN_CLEAR_CACHE)
add_definitions(/DHAVE_BUILTIN_CLEAR_CACHE)
endif()
endif()

View File

@@ -37,7 +37,6 @@
#include "common/Platform.h" #include "common/Platform.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
#include "crypto/CryptoNight.h"
#include "Mem.h" #include "Mem.h"
#include "net/Network.h" #include "net/Network.h"
#include "Summary.h" #include "Summary.h"

View File

@@ -24,9 +24,13 @@
*/ */
#include "common/utils/mm_malloc.h" #include <limits>
#include "crypto/CryptoNight.h"
#include "crypto/CryptoNight_constants.h"
#include "crypto/cn/CryptoNight_constants.h"
#include "crypto/cn/CryptoNight.h"
#include "crypto/common/portable/mm_malloc.h"
#include "crypto/common/VirtualMemory.h"
#include "Mem.h" #include "Mem.h"
@@ -51,13 +55,9 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count)
cryptonight_ctx *c = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 4096)); cryptonight_ctx *c = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 4096));
c->memory = info.memory + (i * cn_select_memory(algorithm)); c->memory = info.memory + (i * cn_select_memory(algorithm));
uint8_t* p = reinterpret_cast<uint8_t*>(allocateExecutableMemory(0x4000)); c->generated_code = reinterpret_cast<cn_mainloop_fun_ms_abi>(xmrig::VirtualMemory::allocateExecutableMemory(0x4000));
c->generated_code = reinterpret_cast<cn_mainloop_fun_ms_abi>(p);
c->generated_code_double = reinterpret_cast<cn_mainloop_fun_ms_abi>(p + 0x2000);
c->generated_code_data.variant = xmrig::VARIANT_MAX; c->generated_code_data.variant = xmrig::VARIANT_MAX;
c->generated_code_data.height = (uint64_t)(-1); c->generated_code_data.height = std::numeric_limits<uint64_t>::max();
c->generated_code_double_data = c->generated_code_data;
ctx[i] = c; ctx[i] = c;
} }
@@ -68,6 +68,10 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count)
void Mem::release(cryptonight_ctx **ctx, size_t count, MemInfo &info) void Mem::release(cryptonight_ctx **ctx, size_t count, MemInfo &info)
{ {
if (info.memory == nullptr) {
return;
}
release(info); release(info);
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {

View File

@@ -39,11 +39,11 @@ struct cryptonight_ctx;
struct MemInfo struct MemInfo
{ {
alignas(16) uint8_t *memory; alignas(16) uint8_t *memory = nullptr;
size_t hugePages; size_t hugePages = 0;
size_t pages; size_t pages = 0;
size_t size; size_t size = 0;
}; };
@@ -60,10 +60,6 @@ public:
static void init(bool enabled); static void init(bool enabled);
static void release(cryptonight_ctx **ctx, size_t count, MemInfo &info); static void release(cryptonight_ctx **ctx, size_t count, MemInfo &info);
static void *allocateExecutableMemory(size_t size);
static void protectExecutableMemory(void *p, size_t size);
static void flushInstructionCache(void *p, size_t size);
static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; } static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; }
private: private:

View File

@@ -29,9 +29,10 @@
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "common/utils/mm_malloc.h"
#include "common/xmrig.h" #include "common/xmrig.h"
#include "crypto/CryptoNight.h" #include "crypto/common/portable/mm_malloc.h"
#include "crypto/common/VirtualMemory.h"
#include "crypto/cn/CryptoNight.h"
#include "Mem.h" #include "Mem.h"
@@ -56,15 +57,8 @@ void Mem::allocate(MemInfo &info, bool enabled)
return; return;
} }
# if defined(__APPLE__) info.memory = static_cast<uint8_t*>(xmrig::VirtualMemory::allocateLargePagesMemory(info.size));
info.memory = static_cast<uint8_t*>(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0)); if (!info.memory) {
# elif defined(__FreeBSD__)
info.memory = static_cast<uint8_t*>(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0));
# else
info.memory = static_cast<uint8_t*>(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
# endif
if (info.memory == MAP_FAILED) {
return allocate(info, false);; return allocate(info, false);;
} }
@@ -87,33 +81,9 @@ void Mem::release(MemInfo &info)
munlock(info.memory, info.size); munlock(info.memory, info.size);
} }
munmap(info.memory, info.size); xmrig::VirtualMemory::freeLargePagesMemory(info.memory, info.size);
} }
else { else {
_mm_free(info.memory); _mm_free(info.memory);
} }
} }
void *Mem::allocateExecutableMemory(size_t size)
{
# if defined(__APPLE__)
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
# else
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
# endif
}
void Mem::protectExecutableMemory(void *p, size_t size)
{
mprotect(p, size, PROT_READ | PROT_EXEC);
}
void Mem::flushInstructionCache(void *p, size_t size)
{
# ifndef __FreeBSD__
__builtin___clear_cache(reinterpret_cast<char*>(p), reinterpret_cast<char*>(p) + size);
# endif
}

View File

@@ -31,10 +31,11 @@
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "common/utils/mm_malloc.h"
#include "common/xmrig.h" #include "common/xmrig.h"
#include "crypto/CryptoNight.h" #include "crypto/common/portable/mm_malloc.h"
#include "crypto/CryptoNight_constants.h" #include "crypto/common/VirtualMemory.h"
#include "crypto/cn/CryptoNight_constants.h"
#include "crypto/cn/CryptoNight.h"
#include "Mem.h" #include "Mem.h"
@@ -163,7 +164,7 @@ void Mem::allocate(MemInfo &info, bool enabled)
return; return;
} }
info.memory = static_cast<uint8_t*>(VirtualAlloc(nullptr, info.size, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE)); info.memory = static_cast<uint8_t*>(xmrig::VirtualMemory::allocateLargePagesMemory(info.size));
if (info.memory) { if (info.memory) {
info.hugePages = info.pages; info.hugePages = info.pages;
@@ -177,28 +178,9 @@ void Mem::allocate(MemInfo &info, bool enabled)
void Mem::release(MemInfo &info) void Mem::release(MemInfo &info)
{ {
if (info.hugePages) { if (info.hugePages) {
VirtualFree(info.memory, 0, MEM_RELEASE); xmrig::VirtualMemory::freeLargePagesMemory(info.memory, info.size);
} }
else { else {
_mm_free(info.memory); _mm_free(info.memory);
} }
} }
void *Mem::allocateExecutableMemory(size_t size)
{
return VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}
void Mem::protectExecutableMemory(void *p, size_t size)
{
DWORD oldProtect;
VirtualProtect(p, size, PAGE_EXECUTE_READ, &oldProtect);
}
void Mem::flushInstructionCache(void *p, size_t size)
{
::FlushInstructionCache(GetCurrentProcess(), p, size);
}

View File

@@ -33,7 +33,7 @@
#include "common/cpu/Cpu.h" #include "common/cpu/Cpu.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
#include "crypto/Asm.h" #include "crypto/cn/Asm.h"
#include "Mem.h" #include "Mem.h"
#include "Summary.h" #include "Summary.h"
#include "version.h" #include "version.h"

View File

@@ -38,6 +38,7 @@
#include "api/v1/ApiRouter.h" #include "api/v1/ApiRouter.h"
#include "base/kernel/Base.h" #include "base/kernel/Base.h"
#include "base/tools/Buffer.h" #include "base/tools/Buffer.h"
#include "base/tools/Chrono.h"
#include "common/crypto/keccak.h" #include "common/crypto/keccak.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "core/Controller.h" #include "core/Controller.h"
@@ -53,7 +54,8 @@ xmrig::Api::Api(Base *base) :
m_base(base), m_base(base),
m_id(), m_id(),
m_workerId(), m_workerId(),
m_httpd(nullptr) m_httpd(nullptr),
m_timestamp(Chrono::steadyMSecs())
{ {
base->addListener(this); base->addListener(this);
@@ -118,9 +120,12 @@ void xmrig::Api::exec(IApiRequest &request)
using namespace rapidjson; using namespace rapidjson;
if (request.method() == IApiRequest::METHOD_GET && (request.url() == "/1/summary" || request.url() == "/api.json")) { if (request.method() == IApiRequest::METHOD_GET && (request.url() == "/1/summary" || request.url() == "/api.json")) {
auto &allocator = request.doc().GetAllocator();
request.accept(); request.accept();
request.reply().AddMember("id", StringRef(m_id), request.doc().GetAllocator()); request.reply().AddMember("id", StringRef(m_id), allocator);
request.reply().AddMember("worker_id", StringRef(m_workerId), request.doc().GetAllocator());; request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
request.reply().AddMember("uptime", (Chrono::steadyMSecs() - m_timestamp) / 1000, allocator);
} }
for (IApiListener *listener : m_listeners) { for (IApiListener *listener : m_listeners) {

View File

@@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include <stdint.h>
#include "base/kernel/interfaces/IBaseListener.h" #include "base/kernel/interfaces/IBaseListener.h"
@@ -72,6 +73,7 @@ private:
char m_workerId[128]; char m_workerId[128];
Httpd *m_httpd; Httpd *m_httpd;
std::vector<IApiListener *> m_listeners; std::vector<IApiListener *> m_listeners;
uint64_t m_timestamp;
}; };

View File

@@ -40,13 +40,15 @@
#include "workers/Workers.h" #include "workers/Workers.h"
static inline double normalize(double d) static inline rapidjson::Value normalize(double d)
{ {
using namespace rapidjson;
if (!isnormal(d)) { if (!isnormal(d)) {
return 0.0; return Value(kNullType);
} }
return floor(d * 100.0) / 100.0; return Value(floor(d * 100.0) / 100.0);
} }
@@ -142,7 +144,6 @@ void xmrig::ApiRouter::getMiner(rapidjson::Value &reply, rapidjson::Document &do
reply.AddMember("kind", APP_KIND, allocator); reply.AddMember("kind", APP_KIND, allocator);
reply.AddMember("ua", StringRef(Platform::userAgent()), allocator); reply.AddMember("ua", StringRef(Platform::userAgent()), allocator);
reply.AddMember("cpu", cpu, allocator); reply.AddMember("cpu", cpu, allocator);
reply.AddMember("algo", StringRef(m_base->config()->algorithm().shortName()), allocator);
reply.AddMember("hugepages", Workers::hugePages() > 0, allocator); reply.AddMember("hugepages", Workers::hugePages() > 0, allocator);
reply.AddMember("donate_level", m_base->config()->pools().donateLevel(), allocator); reply.AddMember("donate_level", m_base->config()->pools().donateLevel(), allocator);
} }

View File

@@ -160,7 +160,7 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
m_http.load(chain.getObject("http")); m_http.load(chain.getObject("http"));
# endif # endif
m_algorithm.parseAlgorithm(reader.getString("algo")); m_algorithm.parseAlgorithm(reader.getString("algo", "cn"));
m_pools.load(reader.getArray("pools")); m_pools.load(reader.getArray("pools"));
m_pools.setDonateLevel(reader.getInt("donate-level", kDefaultDonateLevel)); m_pools.setDonateLevel(reader.getInt("donate-level", kDefaultDonateLevel));

View File

@@ -26,7 +26,7 @@
#define XMRIG_ICONFIG_H #define XMRIG_ICONFIG_H
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h" #include "rapidjson/fwd.h"

View File

@@ -26,7 +26,7 @@
#define XMRIG_ICONFIGTRANSFORM_H #define XMRIG_ICONFIGTRANSFORM_H
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h" #include "rapidjson/fwd.h"

View File

@@ -37,6 +37,7 @@
#endif #endif
#include "base/io/json/Json.h"
#include "base/io/json/JsonRequest.h" #include "base/io/json/JsonRequest.h"
#include "base/io/log/Log.h" #include "base/io/log/Log.h"
#include "base/kernel/interfaces/IClientListener.h" #include "base/kernel/interfaces/IClientListener.h"
@@ -344,13 +345,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
} }
} }
if (params.HasMember("height")) { job.setSeedHash(Json::getString(params, "seed_hash"));
const rapidjson::Value &variant = params["height"]; job.setHeight(Json::getUint64(params, "height"));
if (variant.IsUint64()) {
job.setHeight(variant.GetUint64());
}
}
if (!verifyAlgorithm(job.algorithm())) { if (!verifyAlgorithm(job.algorithm())) {
*code = 6; *code = 6;

View File

@@ -40,7 +40,7 @@
#include "base/net/stratum/SubmitResult.h" #include "base/net/stratum/SubmitResult.h"
#include "base/net/tools/RecvBuf.h" #include "base/net/tools/RecvBuf.h"
#include "base/net/tools/Storage.h" #include "base/net/tools/Storage.h"
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
typedef struct bio_st BIO; typedef struct bio_st BIO;

View File

@@ -220,6 +220,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value &params, int *code)
return false; return false;
} }
job.setSeedHash(Json::getString(params, "seed_hash"));
job.setHeight(Json::getUint64(params, kHeight)); job.setHeight(Json::getUint64(params, kHeight));
job.setDiff(Json::getUint64(params, "difficulty")); job.setDiff(Json::getUint64(params, "difficulty"));
job.setId(blocktemplate.data() + blocktemplate.size() - 32); job.setId(blocktemplate.data() + blocktemplate.size() - 32);

View File

@@ -42,7 +42,8 @@ xmrig::Job::Job() :
m_diff(0), m_diff(0),
m_height(0), m_height(0),
m_target(0), m_target(0),
m_blob() m_blob(),
m_seedHash()
{ {
} }
@@ -58,7 +59,8 @@ xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Str
m_diff(0), m_diff(0),
m_height(0), m_height(0),
m_target(0), m_target(0),
m_blob() m_blob(),
m_seedHash()
{ {
} }
@@ -102,24 +104,6 @@ bool xmrig::Job::setBlob(const char *blob)
m_algorithm.setVariant(variant()); m_algorithm.setVariant(variant());
} }
if (!m_algorithm.isForced()) {
if (m_algorithm.variant() == VARIANT_XTL && m_blob[0] >= 9) {
m_algorithm.setVariant(VARIANT_HALF);
}
else if (m_algorithm.variant() == VARIANT_MSR && m_blob[0] >= 8) {
m_algorithm.setVariant(VARIANT_HALF);
}
else if (m_algorithm.variant() == VARIANT_WOW && m_blob[0] < 11) {
m_algorithm.setVariant(VARIANT_2);
}
else if (m_algorithm.variant() == VARIANT_RWZ && m_blob[0] < 12) {
m_algorithm.setVariant(VARIANT_2);
}
else if (m_algorithm.variant() == VARIANT_ZLS && m_blob[0] < 8) {
m_algorithm.setVariant(VARIANT_2);
}
}
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
memset(m_rawBlob, 0, sizeof(m_rawBlob)); memset(m_rawBlob, 0, sizeof(m_rawBlob));
memcpy(m_rawBlob, blob, m_size * 2); memcpy(m_rawBlob, blob, m_size * 2);
@@ -129,6 +113,20 @@ bool xmrig::Job::setBlob(const char *blob)
} }
bool xmrig::Job::setSeedHash(const char *hash)
{
if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2)) {
return false;
}
# ifdef XMRIG_PROXY_PROJECT
m_rawSeedHash = hash;
# endif
return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash);
}
bool xmrig::Job::setTarget(const char *target) bool xmrig::Job::setTarget(const char *target)
{ {
if (!target) { if (!target) {

View File

@@ -33,7 +33,7 @@
#include "base/tools/String.h" #include "base/tools/String.h"
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
namespace xmrig { namespace xmrig {
@@ -52,6 +52,7 @@ public:
bool isEqual(const Job &other) const; bool isEqual(const Job &other) const;
bool setBlob(const char *blob); bool setBlob(const char *blob);
bool setSeedHash(const char *hash);
bool setTarget(const char *target); bool setTarget(const char *target);
void setAlgorithm(const char *algo); void setAlgorithm(const char *algo);
void setDiff(uint64_t diff); void setDiff(uint64_t diff);
@@ -64,6 +65,7 @@ public:
inline const String &id() const { return m_id; } inline const String &id() const { return m_id; }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); } inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); }
inline const uint8_t *blob() const { return m_blob; } inline const uint8_t *blob() const { return m_blob; }
inline const uint8_t *seedHash() const { return m_seedHash; }
inline int poolId() const { return m_poolId; } inline int poolId() const { return m_poolId; }
inline int threadId() const { return m_threadId; } inline int threadId() const { return m_threadId; }
inline size_t size() const { return m_size; } inline size_t size() const { return m_size; }
@@ -81,9 +83,10 @@ public:
inline void setVariant(int variant) { m_algorithm.parseVariant(variant); } inline void setVariant(int variant) { m_algorithm.parseVariant(variant); }
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
inline char *rawBlob() { return m_rawBlob; } inline char *rawBlob() { return m_rawBlob; }
inline const char *rawBlob() const { return m_rawBlob; } inline const char *rawBlob() const { return m_rawBlob; }
inline const char *rawTarget() const { return m_rawTarget; } inline const char *rawTarget() const { return m_rawTarget; }
inline const String &rawSeedHash() const { return m_rawSeedHash; }
# endif # endif
static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast<uint32_t*>(blob + 39); } static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast<uint32_t*>(blob + 39); }
@@ -107,10 +110,12 @@ private:
uint64_t m_height; uint64_t m_height;
uint64_t m_target; uint64_t m_target;
uint8_t m_blob[kMaxBlobSize]; uint8_t m_blob[kMaxBlobSize];
uint8_t m_seedHash[32];
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
char m_rawBlob[kMaxBlobSize * 2 + 8]; char m_rawBlob[kMaxBlobSize * 2 + 8];
char m_rawTarget[24]; char m_rawTarget[24];
String m_rawSeedHash;
# endif # endif
}; };

View File

@@ -517,6 +517,7 @@ void xmrig::Pool::rebuild()
addVariant(VARIANT_RWZ); addVariant(VARIANT_RWZ);
addVariant(VARIANT_ZLS); addVariant(VARIANT_ZLS);
addVariant(VARIANT_DOUBLE); addVariant(VARIANT_DOUBLE);
addVariant(VARIANT_RX_WOW);
addVariant(VARIANT_AUTO); addVariant(VARIANT_AUTO);
# endif # endif
} }

View File

@@ -32,7 +32,7 @@
#include "base/tools/String.h" #include "base/tools/String.h"
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h" #include "rapidjson/fwd.h"

View File

@@ -89,7 +89,7 @@ void xmrig::FailoverStrategy::add(const Pool &pool)
int64_t xmrig::FailoverStrategy::submit(const JobResult &result) int64_t xmrig::FailoverStrategy::submit(const JobResult &result)
{ {
if (m_active == -1) { if (!isActive()) {
return -1; return -1;
} }

View File

@@ -52,7 +52,7 @@ public:
protected: protected:
inline bool isActive() const override { return m_active >= 0; } inline bool isActive() const override { return m_active >= 0; }
inline IClient *client() const override { return active(); } inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; }
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {} inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
int64_t submit(const JobResult &result) override; int64_t submit(const JobResult &result) override;

View File

@@ -80,6 +80,7 @@ public:
inline String &operator=(char *str) { move(str); return *this; } inline String &operator=(char *str) { move(str); return *this; }
inline String &operator=(const char *str) { copy(str); return *this; } inline String &operator=(const char *str) { copy(str); return *this; }
inline String &operator=(const String &str) { copy(str); return *this; } inline String &operator=(const String &str) { copy(str); return *this; }
inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; }
inline String &operator=(String &&other) { move(std::move(other)); return *this; } inline String &operator=(String &&other) { move(std::move(other)); return *this; }
rapidjson::Value toJSON() const; rapidjson::Value toJSON() const;

View File

@@ -25,7 +25,8 @@
#include <string.h> #include <string.h>
#include <thread> #include <thread>
#if __ARM_FEATURE_CRYPTO
#if __ARM_FEATURE_CRYPTO && !defined(__APPLE__)
# include <sys/auxv.h> # include <sys/auxv.h>
# include <asm/hwcap.h> # include <asm/hwcap.h>
#endif #endif
@@ -47,7 +48,11 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
# endif # endif
# if __ARM_FEATURE_CRYPTO # if __ARM_FEATURE_CRYPTO
# if !defined(__APPLE__)
m_aes = getauxval(AT_HWCAP) & HWCAP_AES; m_aes = getauxval(AT_HWCAP) & HWCAP_AES;
# else
m_aes = true;
# endif
# endif # endif
} }

View File

@@ -36,6 +36,7 @@ enum Algo {
CRYPTONIGHT_LITE, /* CryptoNight (1 MB) */ CRYPTONIGHT_LITE, /* CryptoNight (1 MB) */
CRYPTONIGHT_HEAVY, /* CryptoNight (4 MB) */ CRYPTONIGHT_HEAVY, /* CryptoNight (4 MB) */
CRYPTONIGHT_PICO, /* CryptoNight (256 KB) */ CRYPTONIGHT_PICO, /* CryptoNight (256 KB) */
RANDOM_X, /* RandomX */
ALGO_MAX ALGO_MAX
}; };
@@ -79,6 +80,7 @@ enum Variant {
VARIANT_RWZ = 14, // CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft) VARIANT_RWZ = 14, // CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft)
VARIANT_ZLS = 15, // CryptoNight variant 2 with 3/4 iterations (Zelerius) VARIANT_ZLS = 15, // CryptoNight variant 2 with 3/4 iterations (Zelerius)
VARIANT_DOUBLE = 16, // CryptoNight variant 2 with double iterations (X-CASH) VARIANT_DOUBLE = 16, // CryptoNight variant 2 with double iterations (X-CASH)
VARIANT_RX_WOW = 17, // RandomX (Wownero)
VARIANT_MAX VARIANT_MAX
}; };

View File

@@ -32,8 +32,8 @@
#include "base/kernel/interfaces/IJsonReader.h" #include "base/kernel/interfaces/IJsonReader.h"
#include "common/cpu/Cpu.h" #include "common/cpu/Cpu.h"
#include "core/config/Config.h" #include "core/config/Config.h"
#include "crypto/Asm.h" #include "crypto/cn/Asm.h"
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_constants.h"
#include "rapidjson/document.h" #include "rapidjson/document.h"
#include "rapidjson/filewritestream.h" #include "rapidjson/filewritestream.h"
#include "rapidjson/prettywriter.h" #include "rapidjson/prettywriter.h"
@@ -56,6 +56,12 @@ xmrig::Config::Config() :
} }
bool xmrig::Config::isHwAES() const
{
return (m_aesMode == AES_AUTO ? (Cpu::info()->hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_HW;
}
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName) bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
{ {
if (!BaseConfig::read(reader, fileName)) { if (!BaseConfig::read(reader, fileName)) {
@@ -147,11 +153,10 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
bool xmrig::Config::finalize() bool xmrig::Config::finalize()
{ {
if (!m_threads.cpu.empty()) { if (!m_threads.cpu.empty()) {
m_threads.mode = Advanced; m_threads.mode = Advanced;
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::info()->hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
for (size_t i = 0; i < m_threads.cpu.size(); ++i) { for (size_t i = 0; i < m_threads.cpu.size(); ++i) {
m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm.algo(), m_threads.cpu[i], m_priority, softAES)); m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm.algo(), m_threads.cpu[i], m_priority, !isHwAES()));
} }
return true; return true;
@@ -160,7 +165,8 @@ bool xmrig::Config::finalize()
const AlgoVariant av = getAlgoVariant(); const AlgoVariant av = getAlgoVariant();
m_threads.mode = m_threads.count ? Simple : Automatic; m_threads.mode = m_threads.count ? Simple : Automatic;
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo()) / 1024; const Variant v = m_algorithm.variant();
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo(), v) / 1024;
if (!m_threads.count) { if (!m_threads.count) {
m_threads.count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage); m_threads.count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
@@ -244,7 +250,7 @@ void xmrig::Config::setThreads(const rapidjson::Value &threads)
xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
{ {
# ifndef XMRIG_NO_AEON # ifdef XMRIG_ALGO_CN_LITE
if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) { if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) {
return getAlgoVariantLite(); return getAlgoVariantLite();
} }
@@ -262,7 +268,7 @@ xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
} }
#ifndef XMRIG_NO_AEON #ifdef XMRIG_ALGO_CN_LITE
xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
{ {
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) { if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {

View File

@@ -67,10 +67,10 @@ public:
Config(); Config();
bool isHwAES() const;
bool read(const IJsonReader &reader, const char *fileName) override; bool read(const IJsonReader &reader, const char *fileName) override;
void getJSON(rapidjson::Document &doc) const override; void getJSON(rapidjson::Document &doc) const override;
inline AesMode aesMode() const { return m_aesMode; }
inline AlgoVariant algoVariant() const { return m_algoVariant; } inline AlgoVariant algoVariant() const { return m_algoVariant; }
inline Assembly assembly() const { return m_assembly; } inline Assembly assembly() const { return m_assembly; }
inline bool isHugePages() const { return m_hugePages; } inline bool isHugePages() const { return m_hugePages; }
@@ -90,7 +90,7 @@ private:
void setThreads(const rapidjson::Value &threads); void setThreads(const rapidjson::Value &threads);
AlgoVariant getAlgoVariant() const; AlgoVariant getAlgoVariant() const;
# ifndef XMRIG_NO_AEON # ifdef XMRIG_ALGO_CN_LITE
AlgoVariant getAlgoVariantLite() const; AlgoVariant getAlgoVariantLite() const;
# endif # endif

View File

@@ -37,15 +37,15 @@ Usage: " APP_ID " [OPTIONS]\n\
Options:\n\ Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\ -a, --algo=ALGO specify the algorithm to use\n\
cryptonight\n" cryptonight\n"
#ifndef XMRIG_NO_AEON #ifdef XMRIG_ALGO_CN_LITE
"\ "\
cryptonight-lite\n" cryptonight-lite\n"
#endif #endif
#ifndef XMRIG_NO_SUMO #ifdef XMRIG_ALGO_CN_HEAVY
"\ "\
cryptonight-heavy\n" cryptonight-heavy\n"
#endif #endif
#ifndef XMRIG_NO_CN_PICO #ifdef XMRIG_ALGO_CN_PICO
"\ "\
cryptonight-pico\n" cryptonight-pico\n"
#endif #endif

View File

@@ -33,7 +33,7 @@
#endif #endif
#include "crypto/Asm.h" #include "crypto/cn/Asm.h"
#include "rapidjson/document.h" #include "rapidjson/document.h"

View File

@@ -6,6 +6,7 @@
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2016-2018 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
@@ -30,14 +31,16 @@
#include <stdint.h> #include <stdint.h>
#if defined _MSC_VER || defined XMRIG_ARM #if defined _MSC_VER || defined XMRIG_ARM
#define ABI_ATTRIBUTE # define ABI_ATTRIBUTE
#else #else
#define ABI_ATTRIBUTE __attribute__((ms_abi)) # define ABI_ATTRIBUTE __attribute__((ms_abi))
#endif #endif
struct cryptonight_ctx; struct cryptonight_ctx;
typedef void(*cn_mainloop_fun_ms_abi)(cryptonight_ctx**) ABI_ATTRIBUTE; typedef void(*cn_mainloop_fun_ms_abi)(cryptonight_ctx**) ABI_ATTRIBUTE;
struct cryptonight_r_data { struct cryptonight_r_data {
int variant; int variant;
uint64_t height; uint64_t height;
@@ -45,17 +48,16 @@ struct cryptonight_r_data {
bool match(const int v, const uint64_t h) const { return (v == variant) && (h == height); } bool match(const int v, const uint64_t h) const { return (v == variant) && (h == height); }
}; };
struct cryptonight_ctx { struct cryptonight_ctx {
alignas(16) uint8_t state[224]; alignas(16) uint8_t state[224];
alignas(16) uint8_t *memory; alignas(16) uint8_t *memory;
uint8_t unused[40]; uint8_t unused[40];
const uint32_t* saes_table; const uint32_t *saes_table;
cn_mainloop_fun_ms_abi generated_code; cn_mainloop_fun_ms_abi generated_code;
cn_mainloop_fun_ms_abi generated_code_double;
cryptonight_r_data generated_code_data; cryptonight_r_data generated_code_data;
cryptonight_r_data generated_code_double_data;
}; };

View File

@@ -29,19 +29,19 @@
#include "common/crypto/keccak.h" #include "common/crypto/keccak.h"
#include "common/utils/mm_malloc.h" #include "crypto/common/portable/mm_malloc.h"
#include "crypto/CryptoNight.h" #include "crypto/cn/CryptoNight_constants.h"
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_monero.h"
#include "crypto/CryptoNight_monero.h" #include "crypto/cn/CryptoNight.h"
#include "crypto/soft_aes.h" #include "crypto/cn/soft_aes.h"
extern "C" extern "C"
{ {
#include "crypto/c_groestl.h" #include "crypto/cn/c_groestl.h"
#include "crypto/c_blake256.h" #include "crypto/cn/c_blake256.h"
#include "crypto/c_jh.h" #include "crypto/cn/c_jh.h"
#include "crypto/c_skein.h" #include "crypto/cn/c_skein.h"
} }
@@ -284,7 +284,7 @@ static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output)
} }
#ifndef XMRIG_NO_CN_GPU #ifdef XMRIG_ALGO_CN_GPU
template<xmrig::Algo ALGO, size_t MEM> template<xmrig::Algo ALGO, size_t MEM>
void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output)
{ {
@@ -583,7 +583,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
} }
#ifndef XMRIG_NO_CN_GPU #ifdef XMRIG_ALGO_CN_GPU
template<size_t ITER, uint32_t MASK> template<size_t ITER, uint32_t MASK>
void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad); void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad);

View File

@@ -70,7 +70,7 @@ template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_HEAVY>() { retur
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_PICO>() { return CRYPTONIGHT_PICO_MEMORY; } template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_PICO>() { return CRYPTONIGHT_PICO_MEMORY; }
inline size_t cn_select_memory(Algo algorithm) inline size_t cn_select_memory(Algo algorithm, Variant v = VARIANT_AUTO)
{ {
switch(algorithm) switch(algorithm)
{ {
@@ -86,6 +86,9 @@ inline size_t cn_select_memory(Algo algorithm)
case CRYPTONIGHT_PICO: case CRYPTONIGHT_PICO:
return CRYPTONIGHT_PICO_MEMORY; return CRYPTONIGHT_PICO_MEMORY;
case RANDOM_X:
return (v == VARIANT_RX_WOW) ? CRYPTONIGHT_LITE_MEMORY : CRYPTONIGHT_MEMORY;
default: default:
break; break;
} }

View File

@@ -179,7 +179,7 @@
#endif #endif
#include "common/xmrig.h" #include "common/xmrig.h"
#include "variant4_random_math.h" #include "crypto/cn/r/variant4_random_math.h"
#define VARIANT4_RANDOM_MATH_INIT(part) \ #define VARIANT4_RANDOM_MATH_INIT(part) \
uint32_t r##part[9]; \ uint32_t r##part[9]; \

View File

@@ -272,7 +272,7 @@ const static uint8_t test_output_double[160] = {
0x5E, 0x2E, 0xC1, 0x80, 0x89, 0x39, 0xB3, 0x54, 0x39, 0x52, 0x0E, 0x69, 0x3D, 0xF6, 0xC5, 0x4A 0x5E, 0x2E, 0xC1, 0x80, 0x89, 0x39, 0xB3, 0x54, 0x39, 0x52, 0x0E, 0x69, 0x3D, 0xF6, 0xC5, 0x4A
}; };
#ifndef XMRIG_NO_AEON #ifdef XMRIG_ALGO_CN_LITE
// "cn-lite/0" // "cn-lite/0"
const static uint8_t test_output_v0_lite[160] = { const static uint8_t test_output_v0_lite[160] = {
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
@@ -304,7 +304,7 @@ const static uint8_t test_output_v1_lite[160] = {
#endif #endif
#ifndef XMRIG_NO_SUMO #ifdef XMRIG_ALGO_CN_HEAVY
// "cn-heavy/0" // "cn-heavy/0"
const static uint8_t test_output_v0_heavy[160] = { const static uint8_t test_output_v0_heavy[160] = {
0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64, 0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64,
@@ -351,7 +351,7 @@ const static uint8_t test_output_tube_heavy[160] = {
#endif #endif
#ifndef XMRIG_NO_CN_PICO #ifdef XMRIG_ALGO_CN_PICO
// "cn-pico/trtl" // "cn-pico/trtl"
const static uint8_t test_output_pico_trtl[160] = { const static uint8_t test_output_pico_trtl[160] = {
0x08, 0xF4, 0x21, 0xD7, 0x83, 0x31, 0x17, 0x30, 0x0E, 0xDA, 0x66, 0xE9, 0x8F, 0x4A, 0x25, 0x69, 0x08, 0xF4, 0x21, 0xD7, 0x83, 0x31, 0x17, 0x30, 0x0E, 0xDA, 0x66, 0xE9, 0x8F, 0x4A, 0x25, 0x69,
@@ -368,7 +368,7 @@ const static uint8_t test_output_pico_trtl[160] = {
#endif #endif
#ifndef XMRIG_NO_CN_GPU #ifdef XMRIG_ALGO_CN_GPU
// "cn/gpu" // "cn/gpu"
const static uint8_t test_output_gpu[160] = { const static uint8_t test_output_gpu[160] = {
0xE5, 0x5C, 0xB2, 0x3E, 0x51, 0x64, 0x9A, 0x59, 0xB1, 0x27, 0xB9, 0x6B, 0x51, 0x5F, 0x2B, 0xF7, 0xE5, 0x5C, 0xB2, 0x3E, 0x51, 0x64, 0x9A, 0x59, 0xB1, 0x27, 0xB9, 0x6B, 0x51, 0x5F, 0x2B, 0xF7,

View File

@@ -37,18 +37,18 @@
#include "common/cpu/Cpu.h" #include "common/cpu/Cpu.h"
#include "common/crypto/keccak.h" #include "common/crypto/keccak.h"
#include "crypto/CryptoNight.h" #include "crypto/cn/CryptoNight.h"
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_constants.h"
#include "crypto/CryptoNight_monero.h" #include "crypto/cn/CryptoNight_monero.h"
#include "crypto/soft_aes.h" #include "crypto/cn/soft_aes.h"
extern "C" extern "C"
{ {
#include "crypto/c_groestl.h" #include "crypto/cn/c_groestl.h"
#include "crypto/c_blake256.h" #include "crypto/cn/c_blake256.h"
#include "crypto/c_jh.h" #include "crypto/cn/c_jh.h"
#include "crypto/c_skein.h" #include "crypto/cn/c_skein.h"
} }
@@ -361,7 +361,7 @@ static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output)
} }
#ifndef XMRIG_NO_CN_GPU #ifdef XMRIG_ALGO_CN_GPU
template<xmrig::Algo ALGO, size_t MEM> template<xmrig::Algo ALGO, size_t MEM>
void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output)
{ {
@@ -708,7 +708,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
} }
#ifndef XMRIG_NO_CN_GPU #ifdef XMRIG_ALGO_CN_GPU
template<size_t ITER, uint32_t MASK> template<size_t ITER, uint32_t MASK>
void cn_gpu_inner_avx(const uint8_t *spad, uint8_t *lpad); void cn_gpu_inner_avx(const uint8_t *spad, uint8_t *lpad);
@@ -895,12 +895,12 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
{ {
constexpr size_t MEM = xmrig::cn_select_memory<ALGO>(); constexpr size_t MEM = xmrig::cn_select_memory<ALGO>();
if (xmrig::cn_is_cryptonight_r<VARIANT>() && !ctx[0]->generated_code_double_data.match(VARIANT, height)) { if (xmrig::cn_is_cryptonight_r<VARIANT>() && !ctx[0]->generated_code_data.match(VARIANT, height)) {
V4_Instruction code[256]; V4_Instruction code[256];
const int code_size = v4_random_math_init<VARIANT>(code, height); const int code_size = v4_random_math_init<VARIANT>(code, height);
cn_r_compile_code_double<VARIANT>(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code_double), ASM); cn_r_compile_code_double<VARIANT>(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code), ASM);
ctx[0]->generated_code_double_data.variant = VARIANT; ctx[0]->generated_code_data.variant = VARIANT;
ctx[0]->generated_code_double_data.height = height; ctx[0]->generated_code_data.height = height;
} }
xmrig::keccak(input, size, ctx[0]->state); xmrig::keccak(input, size, ctx[0]->state);
@@ -928,7 +928,7 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
cn_double_double_mainloop_sandybridge_asm(ctx); cn_double_double_mainloop_sandybridge_asm(ctx);
} }
else if (xmrig::cn_is_cryptonight_r<VARIANT>()) { else if (xmrig::cn_is_cryptonight_r<VARIANT>()) {
ctx[0]->generated_code_double(ctx); ctx[0]->generated_code(ctx);
} }
cn_implode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state)); cn_implode_scratchpad<ALGO, MEM, false>(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state));

View File

@@ -26,7 +26,7 @@
#include <arm_neon.h> #include <arm_neon.h>
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_constants.h"
inline void vandq_f32(float32x4_t &v, uint32_t v2) inline void vandq_f32(float32x4_t &v, uint32_t v2)

View File

@@ -22,7 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_constants.h"
#ifdef __GNUC__ #ifdef __GNUC__
# include <x86intrin.h> # include <x86intrin.h>

View File

@@ -22,7 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "crypto/CryptoNight_constants.h" #include "crypto/cn/CryptoNight_constants.h"
#ifdef __GNUC__ #ifdef __GNUC__
# include <x86intrin.h> # include <x86intrin.h>

View File

@@ -24,11 +24,12 @@
*/ */
#include <cstring> #include <cstring>
#include "crypto/CryptoNight_monero.h" #include "crypto/cn/CryptoNight_monero.h"
typedef void(*void_func)(); typedef void(*void_func)();
#include "crypto/asm/CryptonightR_template.h" #include "crypto/cn/asm/CryptonightR_template.h"
#include "crypto/common/VirtualMemory.h"
#include "Mem.h" #include "Mem.h"
@@ -109,7 +110,7 @@ void wow_compile_code(const V4_Instruction* code, int code_size, void* machine_c
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_template_mainloop) - ((const uint8_t*)CryptonightWOW_template_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_template_mainloop) - ((const uint8_t*)CryptonightWOW_template_part1)) - (p - p0));
add_code(p, CryptonightWOW_template_part3, CryptonightWOW_template_end); add_code(p, CryptonightWOW_template_part3, CryptonightWOW_template_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }
void v4_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) void v4_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM)
@@ -123,7 +124,7 @@ void v4_compile_code(const V4_Instruction* code, int code_size, void* machine_co
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_template_mainloop) - ((const uint8_t*)CryptonightR_template_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_template_mainloop) - ((const uint8_t*)CryptonightR_template_part1)) - (p - p0));
add_code(p, CryptonightR_template_part3, CryptonightR_template_end); add_code(p, CryptonightR_template_part3, CryptonightR_template_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }
void wow_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) void wow_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM)
@@ -139,7 +140,7 @@ void wow_compile_code_double(const V4_Instruction* code, int code_size, void* ma
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_template_double_mainloop) - ((const uint8_t*)CryptonightWOW_template_double_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_template_double_mainloop) - ((const uint8_t*)CryptonightWOW_template_double_part1)) - (p - p0));
add_code(p, CryptonightWOW_template_double_part4, CryptonightWOW_template_double_end); add_code(p, CryptonightWOW_template_double_part4, CryptonightWOW_template_double_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }
void v4_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) void v4_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM)
@@ -155,7 +156,7 @@ void v4_compile_code_double(const V4_Instruction* code, int code_size, void* mac
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_template_double_mainloop) - ((const uint8_t*)CryptonightR_template_double_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_template_double_mainloop) - ((const uint8_t*)CryptonightR_template_double_part1)) - (p - p0));
add_code(p, CryptonightR_template_double_part4, CryptonightR_template_double_end); add_code(p, CryptonightR_template_double_part4, CryptonightR_template_double_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }
void wow_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) void wow_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM)
@@ -169,7 +170,7 @@ void wow_soft_aes_compile_code(const V4_Instruction* code, int code_size, void*
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightWOW_soft_aes_template_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightWOW_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightWOW_soft_aes_template_part1)) - (p - p0));
add_code(p, CryptonightWOW_soft_aes_template_part3, CryptonightWOW_soft_aes_template_end); add_code(p, CryptonightWOW_soft_aes_template_part3, CryptonightWOW_soft_aes_template_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }
void v4_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) void v4_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM)
@@ -183,5 +184,5 @@ void v4_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* m
*(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightR_soft_aes_template_part1)) - (p - p0)); *(int*)(p - 4) = static_cast<int>((((const uint8_t*)CryptonightR_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightR_soft_aes_template_part1)) - (p - p0));
add_code(p, CryptonightR_soft_aes_template_part3, CryptonightR_soft_aes_template_end); add_code(p, CryptonightR_soft_aes_template_part3, CryptonightR_soft_aes_template_end);
Mem::flushInstructionCache(machine_code, p - p0); xmrig::VirtualMemory::flushInstructionCache(machine_code, p - p0);
} }

View File

@@ -3,7 +3,7 @@
extern "C" extern "C"
{ {
#include "c_blake256.h" #include "crypto/cn/c_blake256.h"
} }
enum V4_Settings enum V4_Settings

View File

@@ -28,7 +28,7 @@
#if defined(XMRIG_ARM) #if defined(XMRIG_ARM)
# include "crypto/SSE2NEON.h" # include "crypto/cn/SSE2NEON.h"
#elif defined(__GNUC__) #elif defined(__GNUC__)
# include <x86intrin.h> # include <x86intrin.h>
#else #else

View File

@@ -30,7 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include "common/crypto/Algorithm.h" #include "crypto/common/Algorithm.h"
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -70,21 +70,26 @@ static AlgoData const algorithms[] = {
{ "cryptonight/zls", "cn/zls", xmrig::CRYPTONIGHT, xmrig::VARIANT_ZLS }, { "cryptonight/zls", "cn/zls", xmrig::CRYPTONIGHT, xmrig::VARIANT_ZLS },
{ "cryptonight/double", "cn/double", xmrig::CRYPTONIGHT, xmrig::VARIANT_DOUBLE }, { "cryptonight/double", "cn/double", xmrig::CRYPTONIGHT, xmrig::VARIANT_DOUBLE },
# ifndef XMRIG_NO_AEON # ifdef XMRIG_ALGO_RANDOMX
{ "randomx/wow", "rx/wow", xmrig::RANDOM_X, xmrig::VARIANT_RX_WOW },
{ "randomx", "rx", xmrig::RANDOM_X, xmrig::VARIANT_RX_WOW },
# endif
# ifdef XMRIG_ALGO_CN_LITE
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, { "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
{ "cryptonight-light", "cn-light", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, { "cryptonight-light", "cn-light", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
{ "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 }, { "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 },
{ "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 }, { "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 },
# endif # endif
# ifndef XMRIG_NO_SUMO # ifdef XMRIG_ALGO_CN_HEAVY
{ "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_AUTO }, { "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_AUTO },
{ "cryptonight-heavy/0", "cn-heavy/0", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 }, { "cryptonight-heavy/0", "cn-heavy/0", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
{ "cryptonight-heavy/xhv", "cn-heavy/xhv", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV }, { "cryptonight-heavy/xhv", "cn-heavy/xhv", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV },
{ "cryptonight-heavy/tube", "cn-heavy/tube", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE }, { "cryptonight-heavy/tube", "cn-heavy/tube", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE },
# endif # endif
# ifndef XMRIG_NO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
{ "cryptonight-pico/trtl", "cn-pico/trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight-pico/trtl", "cn-pico/trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
{ "cryptonight-pico", "cn-pico", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight-pico", "cn-pico", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
{ "cryptonight-turtle", "cn-trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight-turtle", "cn-trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
@@ -92,7 +97,7 @@ static AlgoData const algorithms[] = {
{ "cryptonight_turtle", "cn_turtle", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight_turtle", "cn_turtle", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
# endif # endif
# ifndef XMRIG_NO_CN_GPU # ifdef XMRIG_ALGO_CN_GPU
{ "cryptonight/gpu", "cn/gpu", xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU }, { "cryptonight/gpu", "cn/gpu", xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU },
# endif # endif
}; };
@@ -138,7 +143,8 @@ static const char *variants[] = {
"r", "r",
"rwz", "rwz",
"zls", "zls",
"double" "double",
"rx/wow",
}; };

View File

@@ -5,7 +5,10 @@
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2018-2019 tevador <tevador@gmail.com>
* Copyright 2016-2019 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
@@ -21,23 +24,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __MM_MALLOC_PORTABLE_H__ #ifndef XMRIG_VIRTUALMEMORY_H
#define __MM_MALLOC_PORTABLE_H__ #define XMRIG_VIRTUALMEMORY_H
#ifdef _WIN32 #include <stddef.h>
# ifdef __GNUC__ #include <stdint.h>
# include <mm_malloc.h>
# else
# include <malloc.h>
# endif
#else
# if defined(XMRIG_ARM) && !defined(__clang__)
# include "aligned_malloc.h"
# else
# include <mm_malloc.h>
# endif
#endif
#endif /* __MM_MALLOC_PORTABLE_H__ */ namespace xmrig {
class VirtualMemory
{
public:
static void *allocateExecutableMemory(size_t size);
static void *allocateLargePagesMemory(size_t size);
static void flushInstructionCache(void *p, size_t size);
static void freeLargePagesMemory(void *p, size_t size);
static void protectExecutableMemory(void *p, size_t size);
static void unprotectExecutableMemory(void *p, size_t size);
};
} /* namespace xmrig */
#endif /* XMRIG_VIRTUALMEMORY_H */

View File

@@ -0,0 +1,90 @@
/* 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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2018-2019 tevador <tevador@gmail.com>
* 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 <stdlib.h>
#include <sys/mman.h>
#include "crypto/common/VirtualMemory.h"
#if defined(__APPLE__)
# include <mach/vm_statistics.h>
#endif
void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size)
{
# if defined(__APPLE__)
void *mem = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
# else
void *mem = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
# endif
return mem == MAP_FAILED ? nullptr : mem;
}
void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size)
{
# if defined(__APPLE__)
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0);
# elif defined(__FreeBSD__)
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0);
# else
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0);
# endif
return mem == MAP_FAILED ? nullptr : mem;
}
void xmrig::VirtualMemory::flushInstructionCache(void *p, size_t size)
{
# ifdef HAVE_BUILTIN_CLEAR_CACHE
__builtin___clear_cache(reinterpret_cast<char*>(p), reinterpret_cast<char*>(p) + size);
# endif
}
void xmrig::VirtualMemory::freeLargePagesMemory(void *p, size_t size)
{
munmap(p, size);
}
void xmrig::VirtualMemory::protectExecutableMemory(void *p, size_t size)
{
mprotect(p, size, PROT_READ | PROT_EXEC);
}
void xmrig::VirtualMemory::unprotectExecutableMemory(void *p, size_t size)
{
mprotect(p, size, PROT_WRITE | PROT_EXEC);
}

View File

@@ -0,0 +1,86 @@
/* 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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2018-2019 tevador <tevador@gmail.com>
* 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 <winsock2.h>
#include <windows.h>
#include "crypto/common/VirtualMemory.h"
namespace xmrig {
constexpr size_t align(size_t pos, size_t align) {
return ((pos - 1) / align + 1) * align;
}
}
void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size)
{
return VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
}
void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size)
{
const size_t min = GetLargePageMinimum();
void *mem = nullptr;
if (min > 0) {
mem = VirtualAlloc(nullptr, align(size, min), MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE);
}
return mem;
}
void xmrig::VirtualMemory::flushInstructionCache(void *p, size_t size)
{
::FlushInstructionCache(GetCurrentProcess(), p, size);
}
void xmrig::VirtualMemory::freeLargePagesMemory(void *p, size_t)
{
VirtualFree(p, 0, MEM_RELEASE);
}
void xmrig::VirtualMemory::protectExecutableMemory(void *p, size_t size)
{
DWORD oldProtect;
VirtualProtect(p, size, PAGE_EXECUTE_READ, &oldProtect);
}
void xmrig::VirtualMemory::unprotectExecutableMemory(void *p, size_t size)
{
DWORD oldProtect;
VirtualProtect(p, size, PAGE_EXECUTE_READWRITE, &oldProtect);
}

View File

@@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* 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 2016-2017 XMRig <support@xmrig.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 * 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
@@ -21,45 +22,50 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __ALIGNED_MALLOC_H__ #ifndef XMRIG_MM_MALLOC_PORTABLE_H
#define __ALIGNED_MALLOC_H__ #define XMRIG_MM_MALLOC_PORTABLE_H
#if defined(XMRIG_ARM) && !defined(__clang__)
#include <stdlib.h> #include <stdlib.h>
#ifndef __cplusplus #ifndef __cplusplus
extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size); extern
#else #else
// Some systems (e.g. those with GNU libc) declare posix_memalign with an extern "C"
// exception specifier. Via an "egregious workaround" in
// Sema::CheckEquivalentExceptionSpec, Clang accepts the following as a valid
// redeclaration of glibc's declaration.
extern "C" int posix_memalign(void **__memptr, size_t __alignment, size_t __size);
#endif #endif
int posix_memalign(void **__memptr, size_t __alignment, size_t __size);
static __inline__ void *__attribute__((__always_inline__, __malloc__)) _mm_malloc(size_t __size, size_t __align) static __inline__ void *__attribute__((__always_inline__, __malloc__)) _mm_malloc(size_t __size, size_t __align)
{ {
if (__align == 1) { if (__align == 1) {
return malloc(__size); return malloc(__size);
} }
if (!(__align & (__align - 1)) && __align < sizeof(void *)) if (!(__align & (__align - 1)) && __align < sizeof(void *)) {
__align = sizeof(void *); __align = sizeof(void *);
}
void *__mallocedMemory; void *__mallocedMemory;
if (posix_memalign(&__mallocedMemory, __align, __size)) { if (posix_memalign(&__mallocedMemory, __align, __size)) {
return 0; return nullptr;
} }
return __mallocedMemory; return __mallocedMemory;
} }
static __inline__ void __attribute__((__always_inline__)) _mm_free(void *__p) static __inline__ void __attribute__((__always_inline__)) _mm_free(void *__p)
{ {
free(__p); free(__p);
} }
#elif defined(_WIN32) && !defined(__GNUC__)
# include <malloc.h>
#else
# include <mm_malloc.h>
#endif
#endif /* __ALIGNED_MALLOC_H__ */
#endif /* XMRIG_MM_MALLOC_PORTABLE_H */

View File

@@ -53,6 +53,7 @@
xmrig::Network::Network(Controller *controller) : xmrig::Network::Network(Controller *controller) :
m_controller(controller),
m_donate(nullptr), m_donate(nullptr),
m_timer(nullptr) m_timer(nullptr)
{ {
@@ -99,7 +100,7 @@ void xmrig::Network::onActive(IStrategy *strategy, IClient *client)
return; return;
} }
m_state.setPool(client->pool().host(), client->pool().port(), client->ip()); m_state.onActive(client);
const char *tlsVersion = client->tlsVersion(); const char *tlsVersion = client->tlsVersion();
LOG_INFO(WHITE_BOLD("use %s ") CYAN_BOLD("%s:%d ") GREEN_BOLD("%s") " " BLACK_BOLD("%s"), LOG_INFO(WHITE_BOLD("use %s ") CYAN_BOLD("%s:%d ") GREEN_BOLD("%s") " " BLACK_BOLD("%s"),
@@ -230,12 +231,18 @@ void xmrig::Network::getConnection(rapidjson::Value &reply, rapidjson::Document
using namespace rapidjson; using namespace rapidjson;
auto &allocator = doc.GetAllocator(); auto &allocator = doc.GetAllocator();
const Algorithm &algo = m_strategy->client()->job().algorithm();
reply.AddMember("algo", StringRef((algo.isValid() ? algo : m_controller->config()->algorithm()).shortName()), allocator);
Value connection(kObjectType); Value connection(kObjectType);
connection.AddMember("pool", StringRef(m_state.pool), allocator); connection.AddMember("pool", StringRef(m_state.pool), allocator);
connection.AddMember("uptime", m_state.connectionTime(), allocator); connection.AddMember("ip", m_state.ip().toJSON(), allocator);
connection.AddMember("ping", m_state.latency(), allocator); connection.AddMember("uptime", m_state.connectionTime(), allocator);
connection.AddMember("failures", m_state.failures, allocator); connection.AddMember("ping", m_state.latency(), allocator);
connection.AddMember("error_log", Value(kArrayType), allocator); connection.AddMember("failures", m_state.failures, allocator);
connection.AddMember("tls", m_state.tls().toJSON(), allocator);
connection.AddMember("tls-fingerprint", m_state.fingerprint().toJSON(), allocator);
connection.AddMember("error_log", Value(kArrayType), allocator);
reply.AddMember("connection", connection, allocator); reply.AddMember("connection", connection, allocator);
} }

View File

@@ -78,6 +78,7 @@ private:
void getResults(rapidjson::Value &reply, rapidjson::Document &doc) const; void getResults(rapidjson::Value &reply, rapidjson::Document &doc) const;
# endif # endif
Controller *m_controller;
IStrategy *m_donate; IStrategy *m_donate;
IStrategy *m_strategy; IStrategy *m_strategy;
NetworkState m_state; NetworkState m_state;

Some files were not shown because too many files have changed in this diff Show More