Update from master (#6)
* can build without microhttpd when WITH_HTTPD=OFF * #341 Fix wrong exit code. * +15% boost with non-AES CPU Performance boost validated on Core 2 Quad processor under Windows 10. But it's Windows/MS Visual C++ specific. * #341 Added option --dry-run. * Remove compilation warnings under MSVC * up to 20% perf increase with Cryptonight with non-AES CPU This time, the performance increase is got with MSVC and GCC. On non-AES CPU, there were an useless load/store SSE2 register. The last MSVC "hack" is replaced by a portable code and he's more complete (a load is saved). On my C2Q6600, with 3 thread, I have +16% with MSVC2015 and +20% with GCC 7.3, compared to official 2.4.4 version. * Compilation error under FreeBSD ULONG is not recognized under this OS, so replaced it with more portable definition. * Update README.md * Update README.md * Update README.md * Correct L2 cache size calculation for Intel Core 2 family This is a workaround for total L2 cache size calculation of Intel Core Solo, Core Duo, Core 2 Duo, Core 2 Quad and their Xeon homologue. These processors have L2 cache shared by 2 cores. There is maybe more CPU with L2 shared cache, but I am sure that these models are concerned and they are not so numerous. A better way would be to modify libcpuid to implement L2 cache counting. * Fix code style, replace tabs to space. * Fix code style, replace tabs to space #2. * Update README.md * Update CHANGELOG.md * Update README.md * Update README.md * v2.4.5 RC * Update CHANGELOG.md * Run internal http server in main loop to avoid requirement to thread synchronization. * Added XMRIG_DEPS cmake variable for unified dependencies. * Use adaptive timer instead of idle handler for HTTP server. * Changes for the Monero v1 PoW * #428 Fixed regression with CPU cache size detection. * Fixed regression (all versions since 2.4 affected) fragmented responses from pool/proxy parsed incorrectly. * Update copyright and move version into Job class. * PoW changes WIP * Added reference hashes. * Added full IPv6 support. * Added option to disable Monero v7 PoW, may useful in future if other coins update their network to v7 without PoW change. * Automatically enable nicehash when use with upcoming xmrig-proxy 2.5. * Added coin field support added in xmrig-proxy 2.5. * Update CHANGELOG.md * Update CHANGELOG.md * Revert changes in Api class, single threaded http server will not be included in 2.5 release. * v2.5.0-dev * Change donation address to separate old and new versions. * Some small fixes. * Better v1 PoW implementation, added variant option. * Added test hashes for AEON. * Change port for AEON donate. * Add -DBUILD_STATIC=ON for static builds See #238 * Simplify variant selection. * #438 Fixed memory release. * Fix for previous commit. * Fix FindUV.cmake and FindMHD.cmake. * Fixes for 32 bit gcc builds. * Remove align.h. * Fix. * Fix FindMHD.cmake * Fix macOS compile. * v2.5.0 * Update README.md * Update README.md
This commit is contained in:
parent
916cf0ae0d
commit
c1f1cb0f47
41 changed files with 842 additions and 363 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
|||
# v2.5.0
|
||||
- [#434](https://github.com/xmrig/xmrig/issues/434) **Added support for Monero v7 PoW, scheduled on March 28.**
|
||||
- Added full IPv6 support.
|
||||
- Added protocol extension, when use the miner with xmrig-proxy 2.5+ no more need manually specify `nicehash` option.
|
||||
- [#123](https://github.com/xmrig/xmrig-proxy/issues/123) Fixed regression (all versions since 2.4 affected) fragmented responses from pool/proxy was parsed incorrectly.
|
||||
- [#428](https://github.com/xmrig/xmrig/issues/428) Fixed regression (version 2.4.5 affected) with CPU cache size detection.
|
||||
|
||||
# v2.4.5
|
||||
- [#324](https://github.com/xmrig/xmrig/pull/324) Fixed build without libmicrohttpd (CMake cache issue).
|
||||
- [#341](https://github.com/xmrig/xmrig/issues/341) Fixed wrong exit code and added command line option `--dry-run`.
|
||||
- [#385](https://github.com/xmrig/xmrig/pull/385) Up to 20% performance increase for non-AES CPU and fixed Intel Core 2 cache detection.
|
||||
|
||||
# v2.4.4
|
||||
- Added libmicrohttpd version to --version output.
|
||||
- Fixed bug in singal handler, in some cases miner wasn't shutdown properly.
|
||||
|
|
|
@ -4,13 +4,13 @@ project(xmrig)
|
|||
option(WITH_LIBCPUID "Use Libcpuid" ON)
|
||||
option(WITH_AEON "CryptoNight-Lite support" ON)
|
||||
option(WITH_HTTPD "HTTP REST API" ON)
|
||||
option(BUILD_STATIC "Build static binary" OFF)
|
||||
|
||||
include (CheckIncludeFile)
|
||||
include (cmake/cpu.cmake)
|
||||
|
||||
|
||||
set(HEADERS
|
||||
src/3rdparty/align.h
|
||||
src/api/Api.h
|
||||
src/api/ApiState.h
|
||||
src/api/NetworkState.h
|
||||
|
@ -29,8 +29,8 @@ set(HEADERS
|
|||
src/log/Log.h
|
||||
src/Mem.h
|
||||
src/net/Client.h
|
||||
src/net/Id.h
|
||||
src/net/Job.h
|
||||
src/net/JobId.h
|
||||
src/net/JobResult.h
|
||||
src/net/Network.h
|
||||
src/net/strategies/DonateStrategy.h
|
||||
|
@ -48,6 +48,7 @@ set(HEADERS
|
|||
src/workers/SingleWorker.h
|
||||
src/workers/Worker.h
|
||||
src/workers/Workers.h
|
||||
src/xmrig.h
|
||||
)
|
||||
|
||||
set(HEADERS_CRYPTO
|
||||
|
@ -57,6 +58,7 @@ set(HEADERS_CRYPTO
|
|||
src/crypto/c_keccak.h
|
||||
src/crypto/c_skein.h
|
||||
src/crypto/CryptoNight.h
|
||||
src/crypto/CryptoNight_monero.h
|
||||
src/crypto/CryptoNight_test.h
|
||||
src/crypto/groestl_tables.h
|
||||
src/crypto/hash.h
|
||||
|
@ -195,6 +197,7 @@ if (WITH_HTTPD)
|
|||
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support")
|
||||
endif()
|
||||
else()
|
||||
set(MHD_LIBRARY "")
|
||||
add_definitions(/DXMRIG_NO_HTTPD)
|
||||
add_definitions(/DXMRIG_NO_API)
|
||||
endif()
|
||||
|
@ -203,5 +206,9 @@ include_directories(src)
|
|||
include_directories(src/3rdparty)
|
||||
include_directories(${UV_INCLUDE_DIR})
|
||||
|
||||
if (BUILD_STATIC)
|
||||
set(CMAKE_EXE_LINKER_FLAGS " -static")
|
||||
endif()
|
||||
|
||||
add_executable(xmrig ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES})
|
||||
target_link_libraries(xmrig ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||
|
|
31
README.md
31
README.md
|
@ -1,4 +1,14 @@
|
|||
# XMRig
|
||||
|
||||
:warning: **You must update miners to version 2.5 before March 28 due [Monero PoW change](https://getmonero.org/2018/02/11/PoW-change-and-key-reuse.html).**
|
||||
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/blob/master/LICENSE)
|
||||
[](https://github.com/xmrig/xmrig/stargazers)
|
||||
[](https://github.com/xmrig/xmrig/network)
|
||||
|
||||
XMRig is a high performance Monero (XMR) CPU miner, with official support for Windows.
|
||||
Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 completely rewritten from scratch on C++.
|
||||
|
||||
|
@ -16,6 +26,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin
|
|||
* [Common Issues](#common-issues)
|
||||
* [Other information](#other-information)
|
||||
* [Donations](#donations)
|
||||
* [Release checksums](#release-checksums)
|
||||
* [Contacts](#contacts)
|
||||
|
||||
## Features
|
||||
|
@ -37,16 +48,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin
|
|||
* Clone with `git clone https://github.com/xmrig/xmrig.git` :hammer: [Build instructions](https://github.com/xmrig/xmrig/wiki/Build).
|
||||
|
||||
## Usage
|
||||
### Basic example
|
||||
```
|
||||
xmrig.exe -o pool.monero.hashvault.pro:5555 -u YOUR_WALLET -p x -k
|
||||
```
|
||||
|
||||
### Failover
|
||||
```
|
||||
xmrig.exe -o pool.monero.hashvault.pro:5555 -u YOUR_WALLET1 -p x -k -o pool.supportxmr.com:5555 -u YOUR_WALLET2 -p x -k
|
||||
```
|
||||
For failover you can add multiple pools, maximum count not limited.
|
||||
Use [config.xmrig.com](https://config.xmrig.com/xmrig) to generate, edit or share configurations.
|
||||
|
||||
### Options
|
||||
```
|
||||
|
@ -117,6 +119,15 @@ Please note performance is highly dependent on system load. The numbers above ar
|
|||
* XMR: `48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD`
|
||||
* BTC: `1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT`
|
||||
|
||||
## Release checksums
|
||||
### SHA-256
|
||||
```
|
||||
232ea929f7219c8de81c7e6fcae7437d40d8128cf55b597a6e1fca0cd77f9f5b xmrig-2.5.0-xenial-amd64.tar.gz/xmrig-2.5.0/xmrig
|
||||
6149ffed21e740cac12aa61b2fdd17248cbd3e51bab2289d2766aad1d29df910 xmrig-2.5.0-gcc-win32.zip/xmrig.exe
|
||||
9c89f80e21db906439a7a1b333b8215dbe07d8e42f98a63f6c10c954288a7108 xmrig-2.5.0-gcc-win64.zip/xmrig.exe
|
||||
b50773c5a74ca9921597a1152e2469ec266cc89eb9765038db7e876f0bcece73 xmrig-2.5.0-msvc-win64.zip/xmrig.exe
|
||||
```
|
||||
|
||||
## Contacts
|
||||
* support@xmrig.com
|
||||
* [reddit](https://www.reddit.com/user/XMRig/)
|
||||
|
|
|
@ -8,15 +8,25 @@
|
|||
find_path(
|
||||
MHD_INCLUDE_DIR
|
||||
NAMES microhttpd.h
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "include"
|
||||
DOC "microhttpd include dir"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_path(MHD_INCLUDE_DIR NAMES microhttpd.h)
|
||||
|
||||
find_library(
|
||||
MHD_LIBRARY
|
||||
NAMES microhttpd microhttpd-10 libmicrohttpd libmicrohttpd-dll
|
||||
NAMES libmicrohttpd.a microhttpd libmicrohttpd
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "lib"
|
||||
DOC "microhttpd library"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_library(MHD_LIBRARY NAMES microhttpd libmicrohttpd)
|
||||
|
||||
set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
|
||||
set(MHD_LIBRARIES ${MHD_LIBRARY})
|
||||
|
||||
|
@ -34,6 +44,6 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
|||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(mhd DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY)
|
||||
find_package_handle_standard_args(MHD DEFAULT_MSG MHD_LIBRARY MHD_INCLUDE_DIR)
|
||||
mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)
|
||||
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
find_path(
|
||||
UV_INCLUDE_DIR
|
||||
NAMES uv.h
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "include"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_path(UV_INCLUDE_DIR NAMES uv.h)
|
||||
find_library(UV_LIBRARY NAMES uv libuv)
|
||||
|
||||
find_library(
|
||||
UV_LIBRARY
|
||||
NAMES libuv.a uv libuv
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "lib"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_library(UV_LIBRARY NAMES libuv.a uv libuv)
|
||||
|
||||
set(UV_LIBRARIES ${UV_LIBRARY})
|
||||
set(UV_INCLUDE_DIRS ${UV_INCLUDE_DIR})
|
||||
|
|
28
src/App.cpp
28
src/App.cpp
|
@ -113,7 +113,7 @@ App::~App()
|
|||
int App::exec()
|
||||
{
|
||||
if (!m_options) {
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
uv_signal_start(&m_sigHUP, App::onSignal, SIGHUP);
|
||||
|
@ -130,6 +130,13 @@ int App::exec()
|
|||
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
|
||||
Summary::print();
|
||||
|
||||
if (m_options->dryRun()) {
|
||||
LOG_NOTICE("OK");
|
||||
release();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifndef XMRIG_NO_API
|
||||
Api::start();
|
||||
# endif
|
||||
|
@ -146,12 +153,7 @@ int App::exec()
|
|||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
||||
delete m_network;
|
||||
|
||||
Options::release();
|
||||
Mem::release();
|
||||
Platform::release();
|
||||
|
||||
release();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -200,6 +202,18 @@ void App::close()
|
|||
}
|
||||
|
||||
|
||||
void App::release()
|
||||
{
|
||||
if (m_network) {
|
||||
delete m_network;
|
||||
}
|
||||
|
||||
Options::release();
|
||||
Mem::release();
|
||||
Platform::release();
|
||||
}
|
||||
|
||||
|
||||
void App::onSignal(uv_signal_t *handle, int signum)
|
||||
{
|
||||
switch (signum)
|
||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
|||
private:
|
||||
void background();
|
||||
void close();
|
||||
void release();
|
||||
|
||||
static void onSignal(uv_signal_t *handle, int signum);
|
||||
|
||||
|
|
|
@ -100,7 +100,13 @@ void Cpu::initCommon()
|
|||
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
|
||||
m_l2_exclusive = true;
|
||||
}
|
||||
else {
|
||||
// Workaround for Intel Pentium Dual-Core, Core Duo, Core 2 Duo, Core 2 Quad and their Xeon homologue
|
||||
// These processors have L2 cache shared by 2 cores.
|
||||
else if (data.vendor == VENDOR_INTEL && data.ext_family == 0x06 && (data.ext_model == 0x0E || data.ext_model == 0x0F || data.ext_model == 0x17)) {
|
||||
int l2_count_per_socket = m_totalCores > 1 ? m_totalCores / 2 : 1;
|
||||
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * l2_count_per_socket * m_sockets : 0;
|
||||
}
|
||||
else{
|
||||
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,13 +24,18 @@
|
|||
|
||||
#ifdef _MSC_VER
|
||||
# include <intrin.h>
|
||||
|
||||
# define bit_AES (1 << 25)
|
||||
# define bit_BMI2 (1 << 8)
|
||||
#else
|
||||
# include <cpuid.h>
|
||||
#endif
|
||||
|
||||
#ifndef bit_AES
|
||||
# define bit_AES (1 << 25)
|
||||
#endif
|
||||
|
||||
#ifndef bit_BMI2
|
||||
# define bit_BMI2 (1 << 8)
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
@ -87,7 +92,7 @@ static inline bool has_aes_ni()
|
|||
int cpu_info[4] = { 0 };
|
||||
cpuid(PROCESSOR_INFO, cpu_info);
|
||||
|
||||
return cpu_info[ECX_Reg] & bit_AES;
|
||||
return (cpu_info[ECX_Reg] & bit_AES) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +100,7 @@ static inline bool has_bmi2() {
|
|||
int cpu_info[4] = { 0 };
|
||||
cpuid(EXTENDED_FEATURES, cpu_info);
|
||||
|
||||
return cpu_info[EBX_Reg] & bit_BMI2;
|
||||
return (cpu_info[EBX_Reg] & bit_BMI2) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
33
src/Mem.cpp
33
src/Mem.cpp
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -28,28 +29,30 @@
|
|||
#include "crypto/CryptoNight.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
bool Mem::m_doubleHash = false;
|
||||
int Mem::m_algo = 0;
|
||||
int Mem::m_flags = 0;
|
||||
int Mem::m_threads = 0;
|
||||
size_t Mem::m_offset = 0;
|
||||
uint8_t *Mem::m_memory = nullptr;
|
||||
bool Mem::m_doubleHash = false;
|
||||
int Mem::m_algo = 0;
|
||||
int Mem::m_flags = 0;
|
||||
int Mem::m_threads = 0;
|
||||
size_t Mem::m_offset = 0;
|
||||
size_t Mem::m_size = 0;
|
||||
alignas(16) uint8_t *Mem::m_memory = nullptr;
|
||||
|
||||
|
||||
cryptonight_ctx *Mem::create(int threadId)
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algo == Options::ALGO_CRYPTONIGHT_LITE) {
|
||||
if (m_algo == xmrig::ALGO_CRYPTONIGHT_LITE) {
|
||||
return createLite(threadId);
|
||||
}
|
||||
# endif
|
||||
|
||||
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MONERO_MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
|
||||
const int ratio = m_doubleHash ? 2 : 1;
|
||||
ctx->memory = &m_memory[MEMORY * (threadId * ratio + 1)];
|
||||
ctx->memory = &m_memory[MONERO_MEMORY * (threadId * ratio + 1)];
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
@ -72,15 +75,15 @@ cryptonight_ctx *Mem::createLite(int threadId) {
|
|||
cryptonight_ctx *ctx;
|
||||
|
||||
if (!m_doubleHash) {
|
||||
const size_t offset = MEMORY * (threadId + 1);
|
||||
const size_t offset = MONERO_MEMORY * (threadId + 1);
|
||||
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[offset + MEMORY_LITE]);
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[offset + AEON_MEMORY]);
|
||||
ctx->memory = &m_memory[offset];
|
||||
return ctx;
|
||||
}
|
||||
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
ctx->memory = &m_memory[MEMORY * (threadId + 1)];
|
||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MONERO_MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||
ctx->memory = &m_memory[MONERO_MEMORY * (threadId + 1)];
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
|
11
src/Mem.h
11
src/Mem.h
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -29,9 +30,6 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "align.h"
|
||||
|
||||
|
||||
struct cryptonight_ctx;
|
||||
|
||||
|
||||
|
@ -61,7 +59,8 @@ private:
|
|||
static int m_flags;
|
||||
static int m_threads;
|
||||
static size_t m_offset;
|
||||
VAR_ALIGN(16, static uint8_t *m_memory);
|
||||
static size_t m_size;
|
||||
alignas(16) static uint8_t *m_memory;
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
static cryptonight_ctx *createLite(int threadId);
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include "log/Log.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
||||
|
@ -45,35 +47,35 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
|||
m_threads = threads;
|
||||
m_doubleHash = doubleHash;
|
||||
|
||||
const int ratio = (doubleHash && algo != Options::ALGO_CRYPTONIGHT_LITE) ? 2 : 1;
|
||||
const size_t size = MEMORY * (threads * ratio + 1);
|
||||
const int ratio = (doubleHash && algo != xmrig::ALGO_CRYPTONIGHT_LITE) ? 2 : 1;
|
||||
m_size = MONERO_MEMORY * (threads * ratio + 1);
|
||||
|
||||
if (!enabled) {
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(m_size, 16));
|
||||
return true;
|
||||
}
|
||||
|
||||
m_flags |= HugepagesAvailable;
|
||||
|
||||
# if defined(__APPLE__)
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0));
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, m_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0));
|
||||
# elif defined(__FreeBSD__)
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0));
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, m_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0));
|
||||
# else
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
||||
m_memory = static_cast<uint8_t*>(mmap(0, m_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0));
|
||||
# endif
|
||||
if (m_memory == MAP_FAILED) {
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(m_size, 16));
|
||||
return true;
|
||||
}
|
||||
|
||||
m_flags |= HugepagesEnabled;
|
||||
|
||||
if (madvise(m_memory, size, MADV_RANDOM | MADV_WILLNEED) != 0) {
|
||||
if (madvise(m_memory, m_size, MADV_RANDOM | MADV_WILLNEED) != 0) {
|
||||
LOG_ERR("madvise failed");
|
||||
}
|
||||
|
||||
if (mlock(m_memory, size) == 0) {
|
||||
if (mlock(m_memory, m_size) == 0) {
|
||||
m_flags |= Lock;
|
||||
}
|
||||
|
||||
|
@ -83,14 +85,12 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
|||
|
||||
void Mem::release()
|
||||
{
|
||||
const int size = MEMORY * (m_threads + 1);
|
||||
|
||||
if (m_flags & HugepagesEnabled) {
|
||||
if (m_flags & Lock) {
|
||||
munlock(m_memory, size);
|
||||
munlock(m_memory, m_size);
|
||||
}
|
||||
|
||||
munmap(m_memory, size);
|
||||
munmap(m_memory, m_size);
|
||||
}
|
||||
else {
|
||||
_mm_free(m_memory);
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include "crypto/CryptoNight.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
|
@ -150,11 +152,11 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
|||
m_threads = threads;
|
||||
m_doubleHash = doubleHash;
|
||||
|
||||
const int ratio = (doubleHash && algo != Options::ALGO_CRYPTONIGHT_LITE) ? 2 : 1;
|
||||
const size_t size = MEMORY * (threads * ratio + 1);
|
||||
const int ratio = (doubleHash && algo != xmrig::ALGO_CRYPTONIGHT_LITE) ? 2 : 1;
|
||||
m_size = MONERO_MEMORY * (threads * ratio + 1);
|
||||
|
||||
if (!enabled) {
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(m_size, 16));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -162,9 +164,9 @@ bool Mem::allocate(int algo, int threads, bool doubleHash, bool enabled)
|
|||
m_flags |= HugepagesAvailable;
|
||||
}
|
||||
|
||||
m_memory = static_cast<uint8_t*>(VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE));
|
||||
m_memory = static_cast<uint8_t*>(VirtualAlloc(NULL, m_size, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE));
|
||||
if (!m_memory) {
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||
m_memory = static_cast<uint8_t*>(_mm_malloc(m_size, 16));
|
||||
}
|
||||
else {
|
||||
m_flags |= HugepagesEnabled;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include "rapidjson/error/en.h"
|
||||
#include "rapidjson/filereadstream.h"
|
||||
#include "version.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
|
@ -74,6 +75,7 @@ Options:\n\
|
|||
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
|
||||
--no-huge-pages disable huge pages support\n\
|
||||
--no-color disable colored output\n\
|
||||
--variant algorithm PoW variant\n\
|
||||
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
||||
--user-agent set custom user-agent string for pool\n\
|
||||
-B, --background run the miner in the background\n\
|
||||
|
@ -101,12 +103,16 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";
|
|||
|
||||
static struct option const options[] = {
|
||||
{ "algo", 1, nullptr, 'a' },
|
||||
{ "api-access-token", 1, nullptr, 4001 },
|
||||
{ "api-port", 1, nullptr, 4000 },
|
||||
{ "api-worker-id", 1, nullptr, 4002 },
|
||||
{ "av", 1, nullptr, 'v' },
|
||||
{ "background", 0, nullptr, 'B' },
|
||||
{ "config", 1, nullptr, 'c' },
|
||||
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||
{ "cpu-priority", 1, nullptr, 1021 },
|
||||
{ "donate-level", 1, nullptr, 1003 },
|
||||
{ "dry-run", 0, nullptr, 5000 },
|
||||
{ "help", 0, nullptr, 'h' },
|
||||
{ "keepalive", 0, nullptr ,'k' },
|
||||
{ "log-file", 1, nullptr, 'l' },
|
||||
|
@ -114,6 +120,7 @@ static struct option const options[] = {
|
|||
{ "nicehash", 0, nullptr, 1006 },
|
||||
{ "no-color", 0, nullptr, 1002 },
|
||||
{ "no-huge-pages", 0, nullptr, 1009 },
|
||||
{ "variant", 1, nullptr, 1010 },
|
||||
{ "pass", 1, nullptr, 'p' },
|
||||
{ "print-time", 1, nullptr, 1007 },
|
||||
{ "retries", 1, nullptr, 'r' },
|
||||
|
@ -126,9 +133,6 @@ static struct option const options[] = {
|
|||
{ "user-agent", 1, nullptr, 1008 },
|
||||
{ "userpass", 1, nullptr, 'O' },
|
||||
{ "version", 0, nullptr, 'V' },
|
||||
{ "api-port", 1, nullptr, 4000 },
|
||||
{ "api-access-token", 1, nullptr, 4001 },
|
||||
{ "api-worker-id", 1, nullptr, 4002 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -141,6 +145,7 @@ static struct option const config_options[] = {
|
|||
{ "cpu-affinity", 1, nullptr, 1020 },
|
||||
{ "cpu-priority", 1, nullptr, 1021 },
|
||||
{ "donate-level", 1, nullptr, 1003 },
|
||||
{ "dry-run", 0, nullptr, 5000 },
|
||||
{ "huge-pages", 0, nullptr, 1009 },
|
||||
{ "log-file", 1, nullptr, 'l' },
|
||||
{ "max-cpu-usage", 1, nullptr, 1004 },
|
||||
|
@ -161,6 +166,7 @@ static struct option const pool_options[] = {
|
|||
{ "user", 1, nullptr, 'u' },
|
||||
{ "userpass", 1, nullptr, 'O' },
|
||||
{ "keepalive", 0, nullptr ,'k' },
|
||||
{ "variant", 1, nullptr, 1010 },
|
||||
{ "nicehash", 0, nullptr, 1006 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
@ -205,6 +211,7 @@ Options::Options(int argc, char **argv) :
|
|||
m_background(false),
|
||||
m_colors(true),
|
||||
m_doubleHash(false),
|
||||
m_dryRun(false),
|
||||
m_hugePages(true),
|
||||
m_ready(false),
|
||||
m_safe(false),
|
||||
|
@ -269,9 +276,7 @@ Options::Options(int argc, char **argv) :
|
|||
}
|
||||
}
|
||||
|
||||
for (Url *url : m_pools) {
|
||||
url->applyExceptions();
|
||||
}
|
||||
adjust();
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
|
@ -377,6 +382,7 @@ bool Options::parseArg(int key, const char *arg)
|
|||
case 1007: /* --print-time */
|
||||
case 1021: /* --cpu-priority */
|
||||
case 4000: /* --api-port */
|
||||
case 1010: /* --variant */
|
||||
return parseArg(key, strtol(arg, nullptr, 10));
|
||||
|
||||
case 'B': /* --background */
|
||||
|
@ -384,6 +390,7 @@ bool Options::parseArg(int key, const char *arg)
|
|||
case 'S': /* --syslog */
|
||||
case 1005: /* --safe */
|
||||
case 1006: /* --nicehash */
|
||||
case 5000: /* --dry-run */
|
||||
return parseBoolean(key, true);
|
||||
|
||||
case 1002: /* --no-color */
|
||||
|
@ -494,6 +501,10 @@ bool Options::parseArg(int key, uint64_t arg)
|
|||
m_printTime = (int) arg;
|
||||
break;
|
||||
|
||||
case 1010: /* --variant */
|
||||
m_pools.back()->setVariant((int) arg);
|
||||
break;
|
||||
|
||||
case 1020: /* --cpu-affinity */
|
||||
if (arg) {
|
||||
m_affinity = arg;
|
||||
|
@ -557,6 +568,10 @@ bool Options::parseBoolean(int key, bool enable)
|
|||
m_colors = enable;
|
||||
break;
|
||||
|
||||
case 5000: /* --dry-run */
|
||||
m_dryRun = enable;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -577,6 +592,14 @@ Url *Options::parseUrl(const char *arg) const
|
|||
}
|
||||
|
||||
|
||||
void Options::adjust()
|
||||
{
|
||||
for (Url *url : m_pools) {
|
||||
url->adjust(m_algo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Options::parseConfig(const char *fileName)
|
||||
{
|
||||
rapidjson::Document doc;
|
||||
|
@ -621,7 +644,7 @@ void Options::parseJSON(const struct option *option, const rapidjson::Value &obj
|
|||
if (option->has_arg && value.IsString()) {
|
||||
parseArg(option->val, value.GetString());
|
||||
}
|
||||
else if (option->has_arg && value.IsUint64()) {
|
||||
else if (option->has_arg && value.IsInt64()) {
|
||||
parseArg(option->val, value.GetUint64());
|
||||
}
|
||||
else if (!option->has_arg && value.IsBool()) {
|
||||
|
@ -687,7 +710,7 @@ bool Options::setAlgo(const char *algo)
|
|||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light")) {
|
||||
m_algo = ALGO_CRYPTONIGHT_LITE;
|
||||
m_algo = xmrig::ALGO_CRYPTONIGHT_LITE;
|
||||
break;
|
||||
}
|
||||
# endif
|
||||
|
@ -705,7 +728,7 @@ bool Options::setAlgo(const char *algo)
|
|||
int Options::getAlgoVariant() const
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
if (m_algo == ALGO_CRYPTONIGHT_LITE) {
|
||||
if (m_algo == xmrig::ALGO_CRYPTONIGHT_LITE) {
|
||||
return getAlgoVariantLite();
|
||||
}
|
||||
# endif
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -39,11 +39,6 @@ struct option;
|
|||
class Options
|
||||
{
|
||||
public:
|
||||
enum Algo {
|
||||
ALGO_CRYPTONIGHT, /* CryptoNight (Monero) */
|
||||
ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
|
||||
};
|
||||
|
||||
enum AlgoVariant {
|
||||
AV0_AUTO,
|
||||
AV1_AESNI,
|
||||
|
@ -59,6 +54,7 @@ public:
|
|||
inline bool background() const { return m_background; }
|
||||
inline bool colors() const { return m_colors; }
|
||||
inline bool doubleHash() const { return m_doubleHash; }
|
||||
inline bool dryRun() const { return m_dryRun; }
|
||||
inline bool hugePages() const { return m_hugePages; }
|
||||
inline bool syslog() const { return m_syslog; }
|
||||
inline const char *apiToken() const { return m_apiToken; }
|
||||
|
@ -95,6 +91,7 @@ private:
|
|||
bool parseArg(int key, uint64_t arg);
|
||||
bool parseBoolean(int key, bool enable);
|
||||
Url *parseUrl(const char *arg) const;
|
||||
void adjust();
|
||||
void parseConfig(const char *fileName);
|
||||
void parseJSON(const struct option *option, const rapidjson::Value &object);
|
||||
void showUsage(int status) const;
|
||||
|
@ -110,6 +107,7 @@ private:
|
|||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_doubleHash;
|
||||
bool m_dryRun;
|
||||
bool m_hugePages;
|
||||
bool m_ready;
|
||||
bool m_safe;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -45,7 +45,19 @@ bool Httpd::start()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, m_port, nullptr, nullptr, &Httpd::handler, this, MHD_OPTION_END);
|
||||
unsigned int flags = 0;
|
||||
if (MHD_is_feature_supported(MHD_FEATURE_EPOLL)) {
|
||||
flags = MHD_USE_EPOLL_LINUX_ONLY | MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY;
|
||||
}
|
||||
else {
|
||||
flags = MHD_USE_SELECT_INTERNALLY;
|
||||
}
|
||||
|
||||
if (MHD_is_feature_supported(MHD_FEATURE_IPv6)) {
|
||||
flags |= MHD_USE_DUAL_STACK;
|
||||
}
|
||||
|
||||
m_daemon = MHD_start_daemon(flags, m_port, nullptr, nullptr, &Httpd::handler, this, MHD_OPTION_END);
|
||||
if (!m_daemon) {
|
||||
LOG_ERR("HTTP Daemon failed to start.");
|
||||
return false;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -46,7 +46,7 @@ NetworkState::NetworkState() :
|
|||
|
||||
int NetworkState::connectionTime() const
|
||||
{
|
||||
return m_active ? ((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
return m_active ? (int)((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ uint32_t NetworkState::avgTime() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (uint32_t) connectionTime() / m_latency.size();
|
||||
return connectionTime() / (uint32_t)m_latency.size();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -24,6 +25,7 @@
|
|||
|
||||
#include "crypto/CryptoNight.h"
|
||||
|
||||
|
||||
#if defined(XMRIG_ARM)
|
||||
# include "crypto/CryptoNight_arm.h"
|
||||
#else
|
||||
|
@ -34,60 +36,74 @@
|
|||
#include "net/Job.h"
|
||||
#include "net/JobResult.h"
|
||||
#include "Options.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
void (*cryptonight_hash_ctx)(const void *input, size_t size, void *output, cryptonight_ctx *ctx) = nullptr;
|
||||
void (*cryptonight_hash_ctx)(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) = nullptr;
|
||||
|
||||
|
||||
static void cryptonight_av1_aesni(const void *input, size_t size, void *output, struct cryptonight_ctx *ctx) {
|
||||
#define CRYPTONIGHT_HASH(NAME, ITERATIONS, MEM, MASK, SOFT_AES) \
|
||||
switch (variant) { \
|
||||
case xmrig::VARIANT_V1: \
|
||||
return cryptonight_##NAME##_hash<ITERATIONS, MEM, MASK, SOFT_AES, xmrig::VARIANT_V1>(input, size, output, ctx); \
|
||||
\
|
||||
case xmrig::VARIANT_NONE: \
|
||||
return cryptonight_##NAME##_hash<ITERATIONS, MEM, MASK, SOFT_AES, xmrig::VARIANT_NONE>(input, size, output, ctx); \
|
||||
\
|
||||
default: \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_av1_aesni(const void *input, size_t size, void *output, struct cryptonight_ctx *ctx, int variant) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
cryptonight_hash<0x80000, MEMORY, 0x1FFFF0, false>(input, size, output, ctx);
|
||||
CRYPTONIGHT_HASH(single, MONERO_ITER, MONERO_MEMORY, MONERO_MASK, false)
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
static void cryptonight_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
cryptonight_double_hash<0x80000, MEMORY, 0x1FFFF0, false>(input, size, output, ctx);
|
||||
CRYPTONIGHT_HASH(double, MONERO_ITER, MONERO_MEMORY, MONERO_MASK, false)
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
cryptonight_hash<0x80000, MEMORY, 0x1FFFF0, true>(input, size, output, ctx);
|
||||
static void cryptonight_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
CRYPTONIGHT_HASH(single, MONERO_ITER, MONERO_MEMORY, MONERO_MASK, true)
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
cryptonight_double_hash<0x80000, MEMORY, 0x1FFFF0, true>(input, size, output, ctx);
|
||||
static void cryptonight_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
CRYPTONIGHT_HASH(double, MONERO_ITER, MONERO_MEMORY, MONERO_MASK, true)
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
static void cryptonight_lite_av1_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
cryptonight_hash<0x40000, MEMORY_LITE, 0xFFFF0, false>(input, size, output, ctx);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_lite_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
static void cryptonight_lite_av1_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
cryptonight_double_hash<0x40000, MEMORY_LITE, 0xFFFF0, false>(input, size, output, ctx);
|
||||
CRYPTONIGHT_HASH(single, AEON_ITER, AEON_MEMORY, AEON_MASK, false)
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_lite_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
cryptonight_hash<0x40000, MEMORY_LITE, 0xFFFF0, true>(input, size, output, ctx);
|
||||
static void cryptonight_lite_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
CRYPTONIGHT_HASH(double, AEON_ITER, AEON_MEMORY, AEON_MASK, false)
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static void cryptonight_lite_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx) {
|
||||
cryptonight_double_hash<0x40000, MEMORY_LITE, 0xFFFF0, true>(input, size, output, ctx);
|
||||
static void cryptonight_lite_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
CRYPTONIGHT_HASH(single, AEON_ITER, AEON_MEMORY, AEON_MASK, true)
|
||||
}
|
||||
|
||||
void (*cryptonight_variations[8])(const void *input, size_t size, void *output, cryptonight_ctx *ctx) = {
|
||||
|
||||
static void cryptonight_lite_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) {
|
||||
CRYPTONIGHT_HASH(double, AEON_ITER, AEON_MEMORY, AEON_MASK, true)
|
||||
}
|
||||
|
||||
void (*cryptonight_variations[8])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) = {
|
||||
cryptonight_av1_aesni,
|
||||
cryptonight_av2_aesni_double,
|
||||
cryptonight_av3_softaes,
|
||||
|
@ -98,7 +114,7 @@ void (*cryptonight_variations[8])(const void *input, size_t size, void *output,
|
|||
cryptonight_lite_av4_softaes_double
|
||||
};
|
||||
#else
|
||||
void (*cryptonight_variations[4])(const void *input, size_t size, void *output, cryptonight_ctx *ctx) = {
|
||||
void (*cryptonight_variations[4])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, int variant) = {
|
||||
cryptonight_av1_aesni,
|
||||
cryptonight_av2_aesni_double,
|
||||
cryptonight_av3_softaes,
|
||||
|
@ -109,7 +125,7 @@ void (*cryptonight_variations[4])(const void *input, size_t size, void *output,
|
|||
|
||||
bool CryptoNight::hash(const Job &job, JobResult &result, cryptonight_ctx *ctx)
|
||||
{
|
||||
cryptonight_hash_ctx(job.blob(), job.size(), result.result, ctx);
|
||||
cryptonight_hash_ctx(job.blob(), job.size(), result.result, ctx, job.variant());
|
||||
|
||||
return *reinterpret_cast<uint64_t*>(result.result + 24) < job.target();
|
||||
}
|
||||
|
@ -122,7 +138,7 @@ bool CryptoNight::init(int algo, int variant)
|
|||
}
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
const int index = algo == Options::ALGO_CRYPTONIGHT_LITE ? (variant + 3) : (variant - 1);
|
||||
const int index = algo == xmrig::ALGO_CRYPTONIGHT_LITE ? (variant + 3) : (variant - 1);
|
||||
# else
|
||||
const int index = variant - 1;
|
||||
# endif
|
||||
|
@ -133,9 +149,9 @@ bool CryptoNight::init(int algo, int variant)
|
|||
}
|
||||
|
||||
|
||||
void CryptoNight::hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx)
|
||||
void CryptoNight::hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx, int variant)
|
||||
{
|
||||
cryptonight_hash_ctx(input, size, output, ctx);
|
||||
cryptonight_hash_ctx(input, size, output, ctx, variant);
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,17 +162,31 @@ bool CryptoNight::selfTest(int algo) {
|
|||
|
||||
char output[64];
|
||||
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16);
|
||||
ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 2, 16);
|
||||
struct cryptonight_ctx *ctx = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 16));
|
||||
ctx->memory = static_cast<uint8_t *>(_mm_malloc(MONERO_MEMORY * 2, 16));
|
||||
|
||||
cryptonight_hash_ctx(test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx(test_input, 76, output, ctx, 0);
|
||||
|
||||
const bool doubleHash = Options::i()->doubleHash();
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
bool rc = memcmp(output, algo == xmrig::ALGO_CRYPTONIGHT_LITE ? test_output_v0_lite : test_output_v0, (doubleHash ? 64 : 32)) == 0;
|
||||
# else
|
||||
bool rc = memcmp(output, test_output_v0, (doubleHash ? 64 : 32)) == 0;
|
||||
# endif
|
||||
|
||||
if (rc) {
|
||||
cryptonight_hash_ctx(test_input, 76, output, ctx, 1);
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
rc = memcmp(output, algo == xmrig::ALGO_CRYPTONIGHT_LITE ? test_output_v1_lite : test_output_v1, (doubleHash ? 64 : 32)) == 0;
|
||||
# else
|
||||
rc = memcmp(output, test_output_v1, (doubleHash ? 64 : 32)) == 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
_mm_free(ctx->memory);
|
||||
_mm_free(ctx);
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
return memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output1 : test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
# else
|
||||
return memcmp(output, test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
# endif
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -29,17 +30,19 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "align.h"
|
||||
#define AEON_MEMORY 1048576
|
||||
#define AEON_MASK 0xFFFF0
|
||||
#define AEON_ITER 0x40000
|
||||
|
||||
|
||||
#define MEMORY 2097152 /* 2 MiB */
|
||||
#define MEMORY_LITE 1048576 /* 1 MiB */
|
||||
#define MONERO_MEMORY 2097152
|
||||
#define MONERO_MASK 0x1FFFF0
|
||||
#define MONERO_ITER 0x80000
|
||||
|
||||
|
||||
struct cryptonight_ctx {
|
||||
VAR_ALIGN(16, uint8_t state0[200]);
|
||||
VAR_ALIGN(16, uint8_t state1[200]);
|
||||
VAR_ALIGN(16, uint8_t* memory);
|
||||
alignas(16) uint8_t state0[200];
|
||||
alignas(16) uint8_t state1[200];
|
||||
alignas(16) uint8_t* memory;
|
||||
};
|
||||
|
||||
|
||||
|
@ -52,7 +55,7 @@ class CryptoNight
|
|||
public:
|
||||
static bool hash(const Job &job, JobResult &result, cryptonight_ctx *ctx);
|
||||
static bool init(int algo, int variant);
|
||||
static void hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx);
|
||||
static void hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx, int variant);
|
||||
|
||||
private:
|
||||
static bool selfTest(int algo);
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016 Imran Yusuff <https://github.com/imranyusuff>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -34,6 +35,7 @@
|
|||
|
||||
|
||||
#include "crypto/CryptoNight.h"
|
||||
#include "crypto/CryptoNight_monero.h"
|
||||
#include "crypto/soft_aes.h"
|
||||
|
||||
|
||||
|
@ -136,20 +138,6 @@ static inline __m128i sl_xor(__m128i tmp1)
|
|||
}
|
||||
|
||||
|
||||
template<uint8_t rcon>
|
||||
static inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2)
|
||||
{
|
||||
// __m128i xout1 = _mm_aeskeygenassist_si128(*xout2, rcon);
|
||||
// xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem
|
||||
// *xout0 = sl_xor(*xout0);
|
||||
// *xout0 = _mm_xor_si128(*xout0, xout1);
|
||||
// xout1 = _mm_aeskeygenassist_si128(*xout0, 0x00);
|
||||
// xout1 = _mm_shuffle_epi32(xout1, 0xAA); // see PSHUFD, set all elems to 3rd elem
|
||||
// *xout2 = sl_xor(*xout2);
|
||||
// *xout2 = _mm_xor_si128(*xout2, xout1);
|
||||
}
|
||||
|
||||
|
||||
template<uint8_t rcon>
|
||||
static inline void soft_aes_genkey_sub(__m128i* xout0, __m128i* xout2)
|
||||
{
|
||||
|
@ -194,14 +182,14 @@ template<bool SOFT_AES>
|
|||
static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7)
|
||||
{
|
||||
if (SOFT_AES) {
|
||||
*x0 = soft_aesenc(*x0, key);
|
||||
*x1 = soft_aesenc(*x1, key);
|
||||
*x2 = soft_aesenc(*x2, key);
|
||||
*x3 = soft_aesenc(*x3, key);
|
||||
*x4 = soft_aesenc(*x4, key);
|
||||
*x5 = soft_aesenc(*x5, key);
|
||||
*x6 = soft_aesenc(*x6, key);
|
||||
*x7 = soft_aesenc(*x7, key);
|
||||
*x0 = soft_aesenc((uint32_t*)x0, key);
|
||||
*x1 = soft_aesenc((uint32_t*)x1, key);
|
||||
*x2 = soft_aesenc((uint32_t*)x2, key);
|
||||
*x3 = soft_aesenc((uint32_t*)x3, key);
|
||||
*x4 = soft_aesenc((uint32_t*)x4, key);
|
||||
*x5 = soft_aesenc((uint32_t*)x5, key);
|
||||
*x6 = soft_aesenc((uint32_t*)x6, key);
|
||||
*x7 = soft_aesenc((uint32_t*)x7, key);
|
||||
}
|
||||
# ifndef XMRIG_ARMv7
|
||||
else {
|
||||
|
@ -344,11 +332,13 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
|||
}
|
||||
|
||||
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||
inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES, int VARIANT>
|
||||
inline void cryptonight_single_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
||||
{
|
||||
keccak(static_cast<const uint8_t*>(input), (int) size, ctx->state0, 200);
|
||||
|
||||
VARIANT1_INIT(0);
|
||||
|
||||
cn_explode_scratchpad<MEM, SOFT_AES>((__m128i*) ctx->state0, (__m128i*) ctx->memory);
|
||||
|
||||
const uint8_t* l0 = ctx->memory;
|
||||
|
@ -361,18 +351,20 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
uint64_t idx0 = h0[0] ^ h0[4];
|
||||
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
__m128i cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
__m128i cx;
|
||||
|
||||
if (SOFT_AES) {
|
||||
cx = soft_aesenc(cx, _mm_set_epi64x(ah0, al0));
|
||||
cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
else {
|
||||
cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
# ifndef XMRIG_ARMv7
|
||||
cx = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah0, al0);
|
||||
# endif
|
||||
}
|
||||
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx));
|
||||
VARIANT1_1(&l0[idx0 & MASK]);
|
||||
idx0 = EXTRACT64(cx);
|
||||
bx0 = cx;
|
||||
|
||||
|
@ -384,8 +376,10 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
al0 += hi;
|
||||
ah0 += lo;
|
||||
|
||||
VARIANT1_2(ah0, 0);
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0;
|
||||
VARIANT1_2(ah0, 0);
|
||||
|
||||
ah0 ^= ch;
|
||||
al0 ^= cl;
|
||||
|
@ -399,12 +393,15 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
}
|
||||
|
||||
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES, int VARIANT>
|
||||
inline void cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, (int) size, ctx->state0, 200);
|
||||
keccak((const uint8_t *) input + size, (int) size, ctx->state1, 200);
|
||||
|
||||
VARIANT1_INIT(0);
|
||||
VARIANT1_INIT(1);
|
||||
|
||||
const uint8_t* l0 = ctx->memory;
|
||||
const uint8_t* l1 = ctx->memory + MEM;
|
||||
uint64_t* h0 = reinterpret_cast<uint64_t*>(ctx->state0);
|
||||
|
@ -425,14 +422,15 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
uint64_t idx1 = h1[0] ^ h1[4];
|
||||
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
__m128i cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
__m128i cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]);
|
||||
__m128i cx0, cx1;
|
||||
|
||||
if (SOFT_AES) {
|
||||
cx0 = soft_aesenc(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc(cx1, _mm_set_epi64x(ah1, al1));
|
||||
cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
else {
|
||||
cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]);
|
||||
# ifndef XMRIG_ARMv7
|
||||
cx0 = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx0, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah0, al0);
|
||||
cx1 = vreinterpretq_m128i_u8(vaesmcq_u8(vaeseq_u8(cx1, vdupq_n_u8(0)))) ^ _mm_set_epi64x(ah1, al1);
|
||||
|
@ -441,6 +439,8 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx0));
|
||||
_mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx1, cx1));
|
||||
VARIANT1_1(&l0[idx0 & MASK]);
|
||||
VARIANT1_1(&l1[idx1 & MASK]);
|
||||
|
||||
idx0 = EXTRACT64(cx0);
|
||||
idx1 = EXTRACT64(cx1);
|
||||
|
@ -456,8 +456,10 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
al0 += hi;
|
||||
ah0 += lo;
|
||||
|
||||
VARIANT1_2(ah0, 0);
|
||||
((uint64_t*) &l0[idx0 & MASK])[0] = al0;
|
||||
((uint64_t*) &l0[idx0 & MASK])[1] = ah0;
|
||||
VARIANT1_2(ah0, 0);
|
||||
|
||||
ah0 ^= ch;
|
||||
al0 ^= cl;
|
||||
|
@ -470,8 +472,10 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
al1 += hi;
|
||||
ah1 += lo;
|
||||
|
||||
VARIANT1_2(ah1, 1);
|
||||
((uint64_t*) &l1[idx1 & MASK])[0] = al1;
|
||||
((uint64_t*) &l1[idx1 & MASK])[1] = ah1;
|
||||
VARIANT1_2(ah1, 1);
|
||||
|
||||
ah1 ^= ch;
|
||||
al1 ^= cl;
|
||||
|
|
51
src/crypto/CryptoNight_monero.h
Normal file
51
src/crypto/CryptoNight_monero.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* 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 2016-2018 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 __CRYPTONIGHT_MONERO_H__
|
||||
#define __CRYPTONIGHT_MONERO_H__
|
||||
|
||||
|
||||
// VARIANT ALTERATIONS
|
||||
#define VARIANT1_INIT(part) \
|
||||
uint64_t tweak1_2_##part = 0; \
|
||||
if (VARIANT > 0) { \
|
||||
tweak1_2_##part = (*reinterpret_cast<const uint64_t*>(reinterpret_cast<const uint8_t*>(input) + 35 + part * size) ^ \
|
||||
*(reinterpret_cast<const uint64_t*>(ctx->state##part) + 24)); \
|
||||
}
|
||||
|
||||
#define VARIANT1_1(p) \
|
||||
if (VARIANT > 0) { \
|
||||
const uint8_t tmp = reinterpret_cast<const uint8_t*>(p)[11]; \
|
||||
static const uint32_t table = 0x75310; \
|
||||
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
|
||||
((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \
|
||||
}
|
||||
|
||||
#define VARIANT1_2(p, part) \
|
||||
if (VARIANT > 0) { \
|
||||
(p) ^= tweak1_2_##part; \
|
||||
}
|
||||
|
||||
|
||||
#endif /* __CRYPTONIGHT_MONERO_H__ */
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -39,7 +40,7 @@ const static uint8_t test_input[152] = {
|
|||
};
|
||||
|
||||
|
||||
const static uint8_t test_output0[64] = {
|
||||
const static uint8_t test_output_v0[64] = {
|
||||
0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66,
|
||||
0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F,
|
||||
0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7,
|
||||
|
@ -47,12 +48,30 @@ const static uint8_t test_output0[64] = {
|
|||
};
|
||||
|
||||
|
||||
// Monero v7
|
||||
const static uint8_t test_output_v1[64] = {
|
||||
0xC9, 0xFA, 0xE8, 0x42, 0x5D, 0x86, 0x88, 0xDC, 0x23, 0x6B, 0xCD, 0xBC, 0x42, 0xFD, 0xB4, 0x2D,
|
||||
0x37, 0x6C, 0x6E, 0xC1, 0x90, 0x50, 0x1A, 0xA8, 0x4B, 0x04, 0xA4, 0xB4, 0xCF, 0x1E, 0xE1, 0x22,
|
||||
0xF2, 0x2D, 0x3D, 0x62, 0x03, 0xD2, 0xA0, 0x8B, 0x41, 0xD9, 0x02, 0x72, 0x78, 0xD8, 0xBC, 0xC9,
|
||||
0x83, 0xAC, 0xAD, 0xA9, 0xB6, 0x8E, 0x52, 0xE3, 0xC6, 0x89, 0x69, 0x2A, 0x50, 0xE9, 0x21, 0xD9
|
||||
};
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
const static uint8_t test_output1[64] = {
|
||||
const static uint8_t test_output_v0_lite[64] = {
|
||||
0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE,
|
||||
0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD,
|
||||
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
|
||||
0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88,
|
||||
0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88
|
||||
};
|
||||
|
||||
|
||||
// AEON v2
|
||||
const static uint8_t test_output_v1_lite[64] = {
|
||||
0x87, 0xC4, 0xE5, 0x70, 0x65, 0x3E, 0xB4, 0xC2, 0xB4, 0x2B, 0x7A, 0x0D, 0x54, 0x65, 0x59, 0x45,
|
||||
0x2D, 0xFA, 0xB5, 0x73, 0xB8, 0x2E, 0xC5, 0x2F, 0x15, 0x2B, 0x7F, 0xF9, 0x8E, 0x79, 0x44, 0x6F,
|
||||
0x6D, 0x8C, 0xDC, 0x44, 0x4E, 0x9B, 0xBB, 0xFD, 0x68, 0xFC, 0x43, 0xFC, 0xD4, 0x85, 0x5B, 0x22,
|
||||
0x8C, 0x8A, 0x1B, 0xD9, 0x1D, 0x9D, 0x00, 0x28, 0x5B, 0xEC, 0x02, 0xB7, 0xCA, 0x2D, 0x67, 0x41
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -34,6 +35,7 @@
|
|||
|
||||
|
||||
#include "crypto/CryptoNight.h"
|
||||
#include "crypto/CryptoNight_monero.h"
|
||||
#include "crypto/soft_aes.h"
|
||||
|
||||
|
||||
|
@ -193,14 +195,14 @@ template<bool SOFT_AES>
|
|||
static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7)
|
||||
{
|
||||
if (SOFT_AES) {
|
||||
*x0 = soft_aesenc(*x0, key);
|
||||
*x1 = soft_aesenc(*x1, key);
|
||||
*x2 = soft_aesenc(*x2, key);
|
||||
*x3 = soft_aesenc(*x3, key);
|
||||
*x4 = soft_aesenc(*x4, key);
|
||||
*x5 = soft_aesenc(*x5, key);
|
||||
*x6 = soft_aesenc(*x6, key);
|
||||
*x7 = soft_aesenc(*x7, key);
|
||||
*x0 = soft_aesenc((uint32_t*)x0, key);
|
||||
*x1 = soft_aesenc((uint32_t*)x1, key);
|
||||
*x2 = soft_aesenc((uint32_t*)x2, key);
|
||||
*x3 = soft_aesenc((uint32_t*)x3, key);
|
||||
*x4 = soft_aesenc((uint32_t*)x4, key);
|
||||
*x5 = soft_aesenc((uint32_t*)x5, key);
|
||||
*x6 = soft_aesenc((uint32_t*)x6, key);
|
||||
*x7 = soft_aesenc((uint32_t*)x7, key);
|
||||
}
|
||||
else {
|
||||
*x0 = _mm_aesenc_si128(*x0, key);
|
||||
|
@ -307,11 +309,13 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
|||
}
|
||||
|
||||
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||
inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES, int VARIANT>
|
||||
inline void cryptonight_single_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, cryptonight_ctx *__restrict__ ctx)
|
||||
{
|
||||
keccak(static_cast<const uint8_t*>(input), (int) size, ctx->state0, 200);
|
||||
|
||||
VARIANT1_INIT(0);
|
||||
|
||||
cn_explode_scratchpad<MEM, SOFT_AES>((__m128i*) ctx->state0, (__m128i*) ctx->memory);
|
||||
|
||||
const uint8_t* l0 = ctx->memory;
|
||||
|
@ -325,16 +329,16 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
__m128i cx;
|
||||
cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
|
||||
if (SOFT_AES) {
|
||||
cx = soft_aesenc(cx, _mm_set_epi64x(ah0, al0));
|
||||
cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
else {
|
||||
else {
|
||||
cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
cx = _mm_aesenc_si128(cx, _mm_set_epi64x(ah0, al0));
|
||||
}
|
||||
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx));
|
||||
VARIANT1_1(&l0[idx0 & MASK]);
|
||||
idx0 = EXTRACT64(cx);
|
||||
bx0 = cx;
|
||||
|
||||
|
@ -346,8 +350,10 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
al0 += hi;
|
||||
ah0 += lo;
|
||||
|
||||
VARIANT1_2(ah0, 0);
|
||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0;
|
||||
VARIANT1_2(ah0, 0);
|
||||
|
||||
ah0 ^= ch;
|
||||
al0 ^= cl;
|
||||
|
@ -361,12 +367,15 @@ inline void cryptonight_hash(const void *__restrict__ input, size_t size, void *
|
|||
}
|
||||
|
||||
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES>
|
||||
template<size_t ITERATIONS, size_t MEM, size_t MASK, bool SOFT_AES, int VARIANT>
|
||||
inline void cryptonight_double_hash(const void *__restrict__ input, size_t size, void *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, (int) size, ctx->state0, 200);
|
||||
keccak((const uint8_t *) input + size, (int) size, ctx->state1, 200);
|
||||
|
||||
VARIANT1_INIT(0);
|
||||
VARIANT1_INIT(1);
|
||||
|
||||
const uint8_t* l0 = ctx->memory;
|
||||
const uint8_t* l1 = ctx->memory + MEM;
|
||||
uint64_t* h0 = reinterpret_cast<uint64_t*>(ctx->state0);
|
||||
|
@ -387,20 +396,23 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
uint64_t idx1 = h1[0] ^ h1[4];
|
||||
|
||||
for (size_t i = 0; i < ITERATIONS; i++) {
|
||||
__m128i cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
__m128i cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]);
|
||||
__m128i cx0, cx1;
|
||||
|
||||
if (SOFT_AES) {
|
||||
cx0 = soft_aesenc(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc(cx1, _mm_set_epi64x(ah1, al1));
|
||||
cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], _mm_set_epi64x(ah0, al0));
|
||||
cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
else {
|
||||
cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]);
|
||||
cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]);
|
||||
cx0 = _mm_aesenc_si128(cx0, _mm_set_epi64x(ah0, al0));
|
||||
cx1 = _mm_aesenc_si128(cx1, _mm_set_epi64x(ah1, al1));
|
||||
}
|
||||
|
||||
_mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx0, cx0));
|
||||
_mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx1, cx1));
|
||||
VARIANT1_1(&l0[idx0 & MASK]);
|
||||
VARIANT1_1(&l1[idx1 & MASK]);
|
||||
|
||||
idx0 = EXTRACT64(cx0);
|
||||
idx1 = EXTRACT64(cx1);
|
||||
|
@ -416,8 +428,10 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
al0 += hi;
|
||||
ah0 += lo;
|
||||
|
||||
VARIANT1_2(ah0, 0);
|
||||
((uint64_t*) &l0[idx0 & MASK])[0] = al0;
|
||||
((uint64_t*) &l0[idx0 & MASK])[1] = ah0;
|
||||
VARIANT1_2(ah0, 0);
|
||||
|
||||
ah0 ^= ch;
|
||||
al0 ^= cl;
|
||||
|
@ -430,8 +444,10 @@ inline void cryptonight_double_hash(const void *__restrict__ input, size_t size,
|
|||
al1 += hi;
|
||||
ah1 += lo;
|
||||
|
||||
VARIANT1_2(ah1, 1);
|
||||
((uint64_t*) &l1[idx1 & MASK])[0] = al1;
|
||||
((uint64_t*) &l1[idx1 & MASK])[1] = ah1;
|
||||
VARIANT1_2(ah1, 1);
|
||||
|
||||
ah1 ^= ch;
|
||||
al1 ^= cl;
|
||||
|
|
|
@ -89,34 +89,34 @@
|
|||
alignas(16) const uint32_t saes_table[4][256] = { saes_data(saes_u0), saes_data(saes_u1), saes_data(saes_u2), saes_data(saes_u3) };
|
||||
alignas(16) const uint8_t saes_sbox[256] = saes_data(saes_h0);
|
||||
|
||||
static inline __m128i soft_aesenc(__m128i in, __m128i key)
|
||||
static inline __m128i soft_aesenc(const uint32_t* in, __m128i key)
|
||||
{
|
||||
const uint32_t x0 = _mm_cvtsi128_si32(in);
|
||||
const uint32_t x1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55));
|
||||
const uint32_t x2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA));
|
||||
const uint32_t x3 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF));
|
||||
const uint32_t x0 = in[0];
|
||||
const uint32_t x1 = in[1];
|
||||
const uint32_t x2 = in[2];
|
||||
const uint32_t x3 = in[3];
|
||||
|
||||
__m128i out = _mm_set_epi32(
|
||||
(saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^ saes_table[3][x2 >> 24]),
|
||||
(saes_table[0][x2 & 0xff] ^ saes_table[1][(x3 >> 8) & 0xff] ^ saes_table[2][(x0 >> 16) & 0xff] ^ saes_table[3][x1 >> 24]),
|
||||
(saes_table[0][x1 & 0xff] ^ saes_table[1][(x2 >> 8) & 0xff] ^ saes_table[2][(x3 >> 16) & 0xff] ^ saes_table[3][x0 >> 24]),
|
||||
(saes_table[0][x0 & 0xff] ^ saes_table[1][(x1 >> 8) & 0xff] ^ saes_table[2][(x2 >> 16) & 0xff] ^ saes_table[3][x3 >> 24]));
|
||||
__m128i out = _mm_set_epi32(
|
||||
(saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^ saes_table[3][x2 >> 24]),
|
||||
(saes_table[0][x2 & 0xff] ^ saes_table[1][(x3 >> 8) & 0xff] ^ saes_table[2][(x0 >> 16) & 0xff] ^ saes_table[3][x1 >> 24]),
|
||||
(saes_table[0][x1 & 0xff] ^ saes_table[1][(x2 >> 8) & 0xff] ^ saes_table[2][(x3 >> 16) & 0xff] ^ saes_table[3][x0 >> 24]),
|
||||
(saes_table[0][x0 & 0xff] ^ saes_table[1][(x1 >> 8) & 0xff] ^ saes_table[2][(x2 >> 16) & 0xff] ^ saes_table[3][x3 >> 24]));
|
||||
|
||||
return _mm_xor_si128(out, key);
|
||||
return _mm_xor_si128(out, key);
|
||||
}
|
||||
|
||||
static inline uint32_t sub_word(uint32_t key)
|
||||
{
|
||||
return (saes_sbox[key >> 24 ] << 24) |
|
||||
(saes_sbox[(key >> 16) & 0xff] << 16 ) |
|
||||
(saes_sbox[(key >> 8) & 0xff] << 8 ) |
|
||||
saes_sbox[key & 0xff];
|
||||
return (saes_sbox[key >> 24 ] << 24) |
|
||||
(saes_sbox[(key >> 16) & 0xff] << 16 ) |
|
||||
(saes_sbox[(key >> 8) & 0xff] << 8 ) |
|
||||
saes_sbox[key & 0xff];
|
||||
}
|
||||
|
||||
#if defined(__clang__) || defined(XMRIG_ARM)
|
||||
static inline uint32_t _rotr(uint32_t value, uint32_t amount)
|
||||
{
|
||||
return (value >> amount) | (value << ((32 - amount) & 31));
|
||||
return (value >> amount) | (value << ((32 - amount) & 31));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -54,6 +54,8 @@ int64_t Client::m_sequence = 1;
|
|||
|
||||
|
||||
Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
m_ipv6(false),
|
||||
m_nicehash(false),
|
||||
m_quiet(false),
|
||||
m_agent(agent),
|
||||
m_listener(listener),
|
||||
|
@ -71,7 +73,7 @@ Client::Client(int id, const char *agent, IClientListener *listener) :
|
|||
|
||||
m_resolver.data = this;
|
||||
|
||||
m_hints.ai_family = PF_INET;
|
||||
m_hints.ai_family = AF_UNSPEC;
|
||||
m_hints.ai_socktype = SOCK_STREAM;
|
||||
m_hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
|
@ -109,19 +111,6 @@ void Client::connect(const Url *url)
|
|||
}
|
||||
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
uv_timer_stop(&m_keepAliveTimer);
|
||||
# endif
|
||||
|
||||
m_expire = 0;
|
||||
m_failures = -1;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void Client::setUrl(const Url *url)
|
||||
{
|
||||
if (!url || !url->isValid()) {
|
||||
|
@ -150,6 +139,19 @@ void Client::tick(uint64_t now)
|
|||
}
|
||||
|
||||
|
||||
bool Client::disconnect()
|
||||
{
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
uv_timer_stop(&m_keepAliveTimer);
|
||||
# endif
|
||||
|
||||
m_expire = 0;
|
||||
m_failures = -1;
|
||||
|
||||
return close();
|
||||
}
|
||||
|
||||
|
||||
int64_t Client::submit(const JobResult &result)
|
||||
{
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
|
@ -167,13 +169,29 @@ int64_t Client::submit(const JobResult &result)
|
|||
# endif
|
||||
|
||||
const size_t size = snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRIu64 ",\"jsonrpc\":\"2.0\",\"method\":\"submit\",\"params\":{\"id\":\"%s\",\"job_id\":\"%s\",\"nonce\":\"%s\",\"result\":\"%s\"}}\n",
|
||||
m_sequence, m_rpcId, result.jobId.data(), nonce, data);
|
||||
m_sequence, m_rpcId.data(), result.jobId.data(), nonce, data);
|
||||
|
||||
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff());
|
||||
return send(size);
|
||||
}
|
||||
|
||||
|
||||
bool Client::close()
|
||||
{
|
||||
if (m_state == UnconnectedState || m_state == ClosingState || !m_socket) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setState(ClosingState);
|
||||
|
||||
if (uv_is_closing(reinterpret_cast<uv_handle_t*>(m_socket)) == 0) {
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(m_socket), Client::onClose);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Client::isCriticalError(const char *message)
|
||||
{
|
||||
if (!message) {
|
||||
|
@ -203,7 +221,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
return false;
|
||||
}
|
||||
|
||||
Job job(m_id, m_url.isNicehash());
|
||||
Job job(m_id, m_nicehash, m_url.algo(), m_url.variant());
|
||||
if (!job.setId(params["job_id"].GetString())) {
|
||||
*code = 3;
|
||||
return false;
|
||||
|
@ -219,6 +237,14 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (params.HasMember("coin")) {
|
||||
job.setCoin(params["coin"].GetString());
|
||||
}
|
||||
|
||||
if (params.HasMember("variant")) {
|
||||
job.setVariant(params["variant"].GetInt());
|
||||
}
|
||||
|
||||
if (m_job == job) {
|
||||
if (!m_quiet) {
|
||||
LOG_WARN("[%s:%u] duplicate job received, reconnect", m_url.host(), m_url.port());
|
||||
|
@ -235,14 +261,16 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
|
||||
bool Client::parseLogin(const rapidjson::Value &result, int *code)
|
||||
{
|
||||
const char *id = result["id"].GetString();
|
||||
if (!id || strlen(id) >= sizeof(m_rpcId)) {
|
||||
if (!m_rpcId.setId(result["id"].GetString())) {
|
||||
*code = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(m_rpcId, 0, sizeof(m_rpcId));
|
||||
memcpy(m_rpcId, id, strlen(id));
|
||||
m_nicehash = m_url.isNicehash();
|
||||
|
||||
if (result.HasMember("extensions")) {
|
||||
parseExtensions(result["extensions"]);
|
||||
}
|
||||
|
||||
return parseJob(result["job"], code);
|
||||
}
|
||||
|
@ -291,21 +319,25 @@ int64_t Client::send(size_t size)
|
|||
}
|
||||
|
||||
|
||||
void Client::close()
|
||||
void Client::connect(const std::vector<addrinfo*> &ipv4, const std::vector<addrinfo*> &ipv6)
|
||||
{
|
||||
if (m_state == UnconnectedState || m_state == ClosingState || !m_socket) {
|
||||
return;
|
||||
addrinfo *addr = nullptr;
|
||||
m_ipv6 = ipv4.empty() && !ipv6.empty();
|
||||
|
||||
if (m_ipv6) {
|
||||
addr = ipv6[ipv6.size() == 1 ? 0 : rand() % ipv6.size()];
|
||||
uv_ip6_name(reinterpret_cast<sockaddr_in6*>(addr->ai_addr), m_ip, 45);
|
||||
}
|
||||
else {
|
||||
addr = ipv4[ipv4.size() == 1 ? 0 : rand() % ipv4.size()];
|
||||
uv_ip4_name(reinterpret_cast<sockaddr_in*>(addr->ai_addr), m_ip, 16);
|
||||
}
|
||||
|
||||
setState(ClosingState);
|
||||
|
||||
if (uv_is_closing(reinterpret_cast<uv_handle_t*>(m_socket)) == 0) {
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(m_socket), Client::onClose);
|
||||
}
|
||||
connect(addr->ai_addr);
|
||||
}
|
||||
|
||||
|
||||
void Client::connect(struct sockaddr *addr)
|
||||
void Client::connect(sockaddr *addr)
|
||||
{
|
||||
setState(ConnectingState);
|
||||
|
||||
|
@ -374,6 +406,11 @@ void Client::parse(char *line, size_t len)
|
|||
|
||||
LOG_DEBUG("[%s:%u] received (%d bytes): \"%s\"", m_url.host(), m_url.port(), len, line);
|
||||
|
||||
if (len < 32 || line[0] != '{') {
|
||||
LOG_ERR("[%s:%u] JSON decode failed", m_url.host(), m_url.port());
|
||||
return;
|
||||
}
|
||||
|
||||
rapidjson::Document doc;
|
||||
if (doc.ParseInsitu(line).HasParseError()) {
|
||||
if (!m_quiet) {
|
||||
|
@ -397,6 +434,24 @@ void Client::parse(char *line, size_t len)
|
|||
}
|
||||
|
||||
|
||||
void Client::parseExtensions(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsArray()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const rapidjson::Value &ext : value.GetArray()) {
|
||||
if (!ext.IsString()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(ext.GetString(), "nicehash") == 0) {
|
||||
m_nicehash = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Client::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error)
|
||||
{
|
||||
if (error.IsObject()) {
|
||||
|
@ -456,7 +511,8 @@ void Client::parseResponse(int64_t id, const rapidjson::Value &result, const rap
|
|||
LOG_ERR("[%s:%u] login error code: %d", m_url.host(), m_url.port(), code);
|
||||
}
|
||||
|
||||
return close();
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
m_failures = 0;
|
||||
|
@ -476,7 +532,7 @@ void Client::parseResponse(int64_t id, const rapidjson::Value &result, const rap
|
|||
|
||||
void Client::ping()
|
||||
{
|
||||
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId));
|
||||
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -582,17 +638,19 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
|||
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) nread));
|
||||
}
|
||||
|
||||
return client->close();
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t) nread > (sizeof(m_buf) - 8 - client->m_recvBufPos)) {
|
||||
return client->close();
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
|
||||
client->m_recvBufPos += nread;
|
||||
|
||||
char* end;
|
||||
char* start = buf->base;
|
||||
char* start = client->m_recvBuf.base;
|
||||
size_t remaining = client->m_recvBufPos;
|
||||
|
||||
while ((end = static_cast<char*>(memchr(start, '\n', remaining))) != nullptr) {
|
||||
|
@ -609,11 +667,11 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
|
|||
return;
|
||||
}
|
||||
|
||||
if (start == buf->base) {
|
||||
if (start == client->m_recvBuf.base) {
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(buf->base, start, remaining);
|
||||
memcpy(client->m_recvBuf.base, start, remaining);
|
||||
client->m_recvBufPos = remaining;
|
||||
}
|
||||
|
||||
|
@ -628,24 +686,27 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
|
|||
|
||||
addrinfo *ptr = res;
|
||||
std::vector<addrinfo*> ipv4;
|
||||
std::vector<addrinfo*> ipv6;
|
||||
|
||||
while (ptr != nullptr) {
|
||||
if (ptr->ai_family == AF_INET) {
|
||||
ipv4.push_back(ptr);
|
||||
}
|
||||
|
||||
if (ptr->ai_family == AF_INET6) {
|
||||
ipv6.push_back(ptr);
|
||||
}
|
||||
|
||||
ptr = ptr->ai_next;
|
||||
}
|
||||
|
||||
if (ipv4.empty()) {
|
||||
LOG_ERR("[%s:%u] DNS error: \"No IPv4 records found\"", client->m_url.host(), client->m_url.port());
|
||||
if (ipv4.empty() && ipv6.empty()) {
|
||||
LOG_ERR("[%s:%u] DNS error: \"No IPv4 (A) or IPv6 (AAAA) records found\"", client->m_url.host(), client->m_url.port());
|
||||
|
||||
uv_freeaddrinfo(res);
|
||||
return client->reconnect();
|
||||
}
|
||||
|
||||
ptr = ipv4[rand() % ipv4.size()];
|
||||
|
||||
uv_ip4_name(reinterpret_cast<sockaddr_in*>(ptr->ai_addr), client->m_ip, 16);
|
||||
|
||||
client->connect(ptr->ai_addr);
|
||||
client->connect(ipv4, ipv6);
|
||||
uv_freeaddrinfo(res);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -27,8 +27,10 @@
|
|||
|
||||
#include <map>
|
||||
#include <uv.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "net/Id.h"
|
||||
#include "net/Job.h"
|
||||
#include "net/SubmitResult.h"
|
||||
#include "net/Url.h"
|
||||
|
@ -56,10 +58,10 @@ public:
|
|||
Client(int id, const char *agent, IClientListener *listener);
|
||||
~Client();
|
||||
|
||||
bool disconnect();
|
||||
int64_t submit(const JobResult &result);
|
||||
void connect();
|
||||
void connect(const Url *url);
|
||||
void disconnect();
|
||||
void setUrl(const Url *url);
|
||||
void tick(uint64_t now);
|
||||
|
||||
|
@ -74,15 +76,17 @@ public:
|
|||
inline void setRetryPause(int ms) { m_retryPause = ms; }
|
||||
|
||||
private:
|
||||
bool close();
|
||||
bool isCriticalError(const char *message);
|
||||
bool parseJob(const rapidjson::Value ¶ms, int *code);
|
||||
bool parseLogin(const rapidjson::Value &result, int *code);
|
||||
int resolve(const char *host);
|
||||
int64_t send(size_t size);
|
||||
void close();
|
||||
void connect(struct sockaddr *addr);
|
||||
void connect(const std::vector<addrinfo*> &ipv4, const std::vector<addrinfo*> &ipv6);
|
||||
void connect(sockaddr *addr);
|
||||
void login();
|
||||
void parse(char *line, size_t len);
|
||||
void parseExtensions(const rapidjson::Value &value);
|
||||
void parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error);
|
||||
void parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error);
|
||||
void ping();
|
||||
|
@ -99,10 +103,11 @@ private:
|
|||
static inline Client *getClient(void *data) { return static_cast<Client*>(data); }
|
||||
|
||||
addrinfo m_hints;
|
||||
bool m_ipv6;
|
||||
bool m_nicehash;
|
||||
bool m_quiet;
|
||||
char m_buf[2048];
|
||||
char m_ip[17];
|
||||
char m_rpcId[64];
|
||||
char m_ip[46];
|
||||
char m_sendBuf[768];
|
||||
const char *m_agent;
|
||||
IClientListener *m_listener;
|
||||
|
@ -120,6 +125,7 @@ private:
|
|||
uv_getaddrinfo_t m_resolver;
|
||||
uv_stream_t *m_stream;
|
||||
uv_tcp_t *m_socket;
|
||||
xmrig::Id m_rpcId;
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
uv_timer_t m_keepAliveTimer;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,40 +21,51 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __JOBID_H__
|
||||
#define __JOBID_H__
|
||||
#ifndef __ID_H__
|
||||
#define __ID_H__
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
class JobId
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Id
|
||||
{
|
||||
public:
|
||||
inline JobId()
|
||||
inline Id() :
|
||||
m_data()
|
||||
{
|
||||
memset(m_data, 0, sizeof(m_data));
|
||||
}
|
||||
|
||||
|
||||
inline JobId(const char *id, size_t sizeFix = 0)
|
||||
inline Id(const char *id, size_t sizeFix = 0)
|
||||
{
|
||||
setId(id, sizeFix);
|
||||
}
|
||||
|
||||
|
||||
inline bool operator==(const JobId &other) const
|
||||
inline bool operator==(const Id &other) const
|
||||
{
|
||||
return memcmp(m_data, other.m_data, sizeof(m_data)) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator!=(const JobId &other) const
|
||||
inline bool operator!=(const Id &other) const
|
||||
{
|
||||
return memcmp(m_data, other.m_data, sizeof(m_data)) != 0;
|
||||
}
|
||||
|
||||
|
||||
Id &operator=(const Id &other)
|
||||
{
|
||||
memcpy(m_data, other.m_data, sizeof(m_data));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline bool setId(const char *id, size_t sizeFix = 0)
|
||||
{
|
||||
memset(m_data, 0, sizeof(m_data));
|
||||
|
@ -80,4 +91,8 @@ private:
|
|||
char m_data[64];
|
||||
};
|
||||
|
||||
#endif /* __JOBID_H__ */
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* __ID_H__ */
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -55,13 +56,32 @@ static inline char hf_bin2hex(unsigned char c)
|
|||
}
|
||||
|
||||
|
||||
Job::Job(int poolId, bool nicehash) :
|
||||
m_nicehash(nicehash),
|
||||
m_poolId(poolId),
|
||||
Job::Job() :
|
||||
m_nicehash(false),
|
||||
m_coin(),
|
||||
m_algo(xmrig::ALGO_CRYPTONIGHT),
|
||||
m_poolId(-2),
|
||||
m_threadId(-1),
|
||||
m_variant(xmrig::VARIANT_AUTO),
|
||||
m_size(0),
|
||||
m_diff(0),
|
||||
m_target(0)
|
||||
m_target(0),
|
||||
m_blob()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Job::Job(int poolId, bool nicehash, int algo, int variant) :
|
||||
m_nicehash(nicehash),
|
||||
m_coin(),
|
||||
m_algo(algo),
|
||||
m_poolId(poolId),
|
||||
m_threadId(-1),
|
||||
m_variant(variant),
|
||||
m_size(0),
|
||||
m_diff(0),
|
||||
m_target(0),
|
||||
m_blob()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -95,11 +115,6 @@ bool Job::setBlob(const char *blob)
|
|||
m_nicehash = true;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
memset(m_rawBlob, 0, sizeof(m_rawBlob));
|
||||
memcpy(m_rawBlob, blob, m_size * 2);
|
||||
# endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -136,16 +151,38 @@ bool Job::setTarget(const char *target)
|
|||
return false;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
memset(m_rawTarget, 0, sizeof(m_rawTarget));
|
||||
memcpy(m_rawTarget, target, len);
|
||||
# endif
|
||||
|
||||
m_diff = toDiff(m_target);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Job::setCoin(const char *coin)
|
||||
{
|
||||
if (!coin || strlen(coin) > 4) {
|
||||
memset(m_coin, 0, sizeof(m_coin));
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(m_coin, coin, sizeof(m_coin));
|
||||
m_algo = strcmp(m_coin, "AEON") == 0 ? xmrig::ALGO_CRYPTONIGHT_LITE : xmrig::ALGO_CRYPTONIGHT;
|
||||
}
|
||||
|
||||
|
||||
void Job::setVariant(int variant)
|
||||
{
|
||||
switch (variant) {
|
||||
case xmrig::VARIANT_AUTO:
|
||||
case xmrig::VARIANT_NONE:
|
||||
case xmrig::VARIANT_V1:
|
||||
m_variant = variant;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Job::fromHex(const char* in, unsigned int len, unsigned char* out)
|
||||
{
|
||||
bool error = false;
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -29,27 +30,32 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "align.h"
|
||||
#include "net/JobId.h"
|
||||
#include "net/Id.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
class Job
|
||||
{
|
||||
public:
|
||||
Job(int poolId = -2, bool nicehash = false);
|
||||
Job();
|
||||
Job(int poolId, bool nicehash, int algo, int variant);
|
||||
~Job();
|
||||
|
||||
bool setBlob(const char *blob);
|
||||
bool setTarget(const char *target);
|
||||
void setCoin(const char *coin);
|
||||
void setVariant(int variant);
|
||||
|
||||
inline bool isNicehash() const { return m_nicehash; }
|
||||
inline bool isValid() const { return m_size > 0 && m_diff > 0; }
|
||||
inline bool setId(const char *id) { return m_id.setId(id); }
|
||||
inline const JobId &id() const { return m_id; }
|
||||
inline const char *coin() const { return m_coin; }
|
||||
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 xmrig::Id &id() const { return m_id; }
|
||||
inline int poolId() const { return m_poolId; }
|
||||
inline int threadId() const { return m_threadId; }
|
||||
inline int variant() const { return (m_variant == xmrig::VARIANT_AUTO ? (m_blob[0] > 6 ? 1 : 0) : m_variant); }
|
||||
inline size_t size() const { return m_size; }
|
||||
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + 39); }
|
||||
inline uint32_t diff() const { return (uint32_t) m_diff; }
|
||||
|
@ -57,11 +63,6 @@ public:
|
|||
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
||||
inline void setThreadId(int threadId) { m_threadId = threadId; }
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
inline char *rawBlob() { return m_rawBlob; }
|
||||
inline const char *rawTarget() const { return m_rawTarget; }
|
||||
# endif
|
||||
|
||||
static bool fromHex(const char* in, unsigned int len, unsigned char* out);
|
||||
static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast<uint32_t*>(blob + 39); }
|
||||
static inline uint64_t toDiff(uint64_t target) { return 0xFFFFFFFFFFFFFFFFULL / target; }
|
||||
|
@ -70,20 +71,17 @@ public:
|
|||
bool operator==(const Job &other) const;
|
||||
|
||||
private:
|
||||
VAR_ALIGN(16, uint8_t m_blob[84]); // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
|
||||
|
||||
bool m_nicehash;
|
||||
char m_coin[5];
|
||||
int m_algo;
|
||||
int m_poolId;
|
||||
int m_threadId;
|
||||
JobId m_id;
|
||||
int m_variant;
|
||||
size_t m_size;
|
||||
uint64_t m_diff;
|
||||
uint64_t m_target;
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
VAR_ALIGN(16, char m_rawBlob[169]);
|
||||
VAR_ALIGN(16, char m_rawTarget[17]);
|
||||
# endif
|
||||
uint8_t m_blob[96]; // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
|
||||
xmrig::Id m_id;
|
||||
};
|
||||
|
||||
#endif /* __JOB_H__ */
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -36,11 +36,11 @@ class JobResult
|
|||
{
|
||||
public:
|
||||
inline JobResult() : poolId(0), diff(0), nonce(0) {}
|
||||
inline JobResult(int poolId, const JobId &jobId, uint32_t nonce, const uint8_t *result, uint32_t diff) :
|
||||
inline JobResult(int poolId, const xmrig::Id &jobId, uint32_t nonce, const uint8_t *result, uint32_t diff) :
|
||||
poolId(poolId),
|
||||
jobId(jobId),
|
||||
diff(diff),
|
||||
nonce(nonce)
|
||||
nonce(nonce),
|
||||
jobId(jobId)
|
||||
{
|
||||
memcpy(this->result, result, sizeof(this->result));
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ public:
|
|||
|
||||
|
||||
int poolId;
|
||||
JobId jobId;
|
||||
uint32_t diff;
|
||||
uint32_t nonce;
|
||||
uint8_t result[32];
|
||||
xmrig::Id jobId;
|
||||
};
|
||||
|
||||
#endif /* __JOBRESULT_H__ */
|
||||
|
|
102
src/net/Url.cpp
102
src/net/Url.cpp
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -28,6 +28,7 @@
|
|||
|
||||
|
||||
#include "net/Url.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -41,6 +42,9 @@ Url::Url() :
|
|||
m_host(nullptr),
|
||||
m_password(nullptr),
|
||||
m_user(nullptr),
|
||||
m_algo(xmrig::ALGO_CRYPTONIGHT),
|
||||
m_variant(xmrig::VARIANT_AUTO),
|
||||
m_url(nullptr),
|
||||
m_port(kDefaultPort)
|
||||
{
|
||||
}
|
||||
|
@ -63,17 +67,23 @@ Url::Url(const char *url) :
|
|||
m_host(nullptr),
|
||||
m_password(nullptr),
|
||||
m_user(nullptr),
|
||||
m_algo(xmrig::ALGO_CRYPTONIGHT),
|
||||
m_variant(xmrig::VARIANT_AUTO),
|
||||
m_url(nullptr),
|
||||
m_port(kDefaultPort)
|
||||
{
|
||||
parse(url);
|
||||
}
|
||||
|
||||
|
||||
Url::Url(const char *host, uint16_t port, const char *user, const char *password, bool keepAlive, bool nicehash) :
|
||||
Url::Url(const char *host, uint16_t port, const char *user, const char *password, bool keepAlive, bool nicehash, int variant) :
|
||||
m_keepAlive(keepAlive),
|
||||
m_nicehash(nicehash),
|
||||
m_password(password ? strdup(password) : nullptr),
|
||||
m_user(user ? strdup(user) : nullptr),
|
||||
m_algo(xmrig::ALGO_CRYPTONIGHT),
|
||||
m_variant(variant),
|
||||
m_url(nullptr),
|
||||
m_port(port)
|
||||
{
|
||||
m_host = strdup(host);
|
||||
|
@ -85,6 +95,10 @@ Url::~Url()
|
|||
free(m_host);
|
||||
free(m_password);
|
||||
free(m_user);
|
||||
|
||||
if (m_url) {
|
||||
delete [] m_url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,6 +119,10 @@ bool Url::parse(const char *url)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (base[0] == '[') {
|
||||
return parseIPv6(base);
|
||||
}
|
||||
|
||||
const char *port = strchr(base, ':');
|
||||
if (!port) {
|
||||
m_host = strdup(base);
|
||||
|
@ -112,9 +130,8 @@ bool Url::parse(const char *url)
|
|||
}
|
||||
|
||||
const size_t size = port++ - base + 1;
|
||||
m_host = static_cast<char*>(malloc(size));
|
||||
m_host = new char[size]();
|
||||
memcpy(m_host, base, size - 1);
|
||||
m_host[size - 1] = '\0';
|
||||
|
||||
m_port = (uint16_t) strtol(port, nullptr, 10);
|
||||
return true;
|
||||
|
@ -139,12 +156,27 @@ bool Url::setUserpass(const char *userpass)
|
|||
}
|
||||
|
||||
|
||||
void Url::applyExceptions()
|
||||
const char *Url::url() const
|
||||
{
|
||||
if (!m_url) {
|
||||
const size_t size = strlen(m_host) + 8;
|
||||
m_url = new char[size];
|
||||
|
||||
snprintf(m_url, size - 1, "%s:%d", m_host, m_port);
|
||||
}
|
||||
|
||||
return m_url;
|
||||
}
|
||||
|
||||
|
||||
void Url::adjust(int algo)
|
||||
{
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_algo = algo;
|
||||
|
||||
if (strstr(m_host, ".nicehash.com")) {
|
||||
m_keepAlive = false;
|
||||
m_nicehash = true;
|
||||
|
@ -178,9 +210,40 @@ void Url::setUser(const char *user)
|
|||
}
|
||||
|
||||
|
||||
void Url::setVariant(int variant)
|
||||
{
|
||||
switch (variant) {
|
||||
case xmrig::VARIANT_AUTO:
|
||||
case xmrig::VARIANT_NONE:
|
||||
case xmrig::VARIANT_V1:
|
||||
m_variant = variant;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Url::operator==(const Url &other) const
|
||||
{
|
||||
if (m_port != other.m_port || m_keepAlive != other.m_keepAlive || m_nicehash != other.m_nicehash) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(host(), other.host()) != 0 || strcmp(user(), other.user()) != 0 || strcmp(password(), other.password()) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Url &Url::operator=(const Url *other)
|
||||
{
|
||||
m_keepAlive = other->m_keepAlive;
|
||||
m_algo = other->m_algo;
|
||||
m_variant = other->m_variant;
|
||||
m_nicehash = other->m_nicehash;
|
||||
m_port = other->m_port;
|
||||
|
||||
|
@ -190,5 +253,32 @@ Url &Url::operator=(const Url *other)
|
|||
setPassword(other->m_password);
|
||||
setUser(other->m_user);
|
||||
|
||||
if (m_url) {
|
||||
delete [] m_url;
|
||||
m_url = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool Url::parseIPv6(const char *addr)
|
||||
{
|
||||
const char *end = strchr(addr, ']');
|
||||
if (!end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *port = strchr(end, ':');
|
||||
if (!port) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t size = end - addr;
|
||||
m_host = new char[size]();
|
||||
memcpy(m_host, addr + 1, size - 1);
|
||||
|
||||
m_port = (uint16_t) strtol(port + 1, nullptr, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
Url();
|
||||
Url(const char *url);
|
||||
Url(const char *host, uint16_t port, const char *user = nullptr, const char *password = nullptr, bool keepAlive = false, bool nicehash = false );
|
||||
Url(const char *host, uint16_t port, const char *user = nullptr, const char *password = nullptr, bool keepAlive = false, bool nicehash = false, int variant = -1);
|
||||
~Url();
|
||||
|
||||
inline bool isKeepAlive() const { return m_keepAlive; }
|
||||
|
@ -46,24 +46,35 @@ public:
|
|||
inline const char *host() const { return m_host; }
|
||||
inline const char *password() const { return m_password ? m_password : kDefaultPassword; }
|
||||
inline const char *user() const { return m_user ? m_user : kDefaultUser; }
|
||||
inline int algo() const { return m_algo; }
|
||||
inline int variant() const { return m_variant; }
|
||||
inline uint16_t port() const { return m_port; }
|
||||
inline void setKeepAlive(bool keepAlive) { m_keepAlive = keepAlive; }
|
||||
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
||||
inline void setVariant(bool monero) { m_variant = monero; }
|
||||
|
||||
bool parse(const char *url);
|
||||
bool setUserpass(const char *userpass);
|
||||
void applyExceptions();
|
||||
const char *url() const;
|
||||
void adjust(int algo);
|
||||
void setPassword(const char *password);
|
||||
void setUser(const char *user);
|
||||
void setVariant(int variant);
|
||||
|
||||
bool operator==(const Url &other) const;
|
||||
Url &operator=(const Url *other);
|
||||
|
||||
private:
|
||||
bool parseIPv6(const char *addr);
|
||||
|
||||
bool m_keepAlive;
|
||||
bool m_nicehash;
|
||||
char *m_host;
|
||||
char *m_password;
|
||||
char *m_user;
|
||||
int m_algo;
|
||||
int m_variant;
|
||||
mutable char *m_url;
|
||||
uint16_t m_port;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -27,6 +27,7 @@
|
|||
#include "net/Job.h"
|
||||
#include "net/strategies/DonateStrategy.h"
|
||||
#include "Options.h"
|
||||
#include "xmrig.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
|
@ -48,7 +49,7 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
|
|||
keccak(reinterpret_cast<const uint8_t *>(user), static_cast<int>(strlen(user)), hash, sizeof(hash));
|
||||
Job::toHex(hash, 32, userId);
|
||||
|
||||
Url *url = new Url("fee.xmrig.com", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 3333 : 443, userId, nullptr, false, true);
|
||||
Url *url = new Url("thanks.xmrig.com", Options::i()->algo() == xmrig::ALGO_CRYPTONIGHT_LITE ? 5555 : 80, userId, nullptr, false, true);
|
||||
|
||||
m_client = new Client(-1, agent, this);
|
||||
m_client->setUrl(url);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2018 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* 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
|
||||
|
@ -27,15 +27,15 @@
|
|||
#define APP_ID "xmrig"
|
||||
#define APP_NAME "XMRig"
|
||||
#define APP_DESC "XMRig CPU miner"
|
||||
#define APP_VERSION "2.4.4"
|
||||
#define APP_VERSION "2.5.0"
|
||||
#define APP_DOMAIN "xmrig.com"
|
||||
#define APP_SITE "www.xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2018 xmrig.com"
|
||||
#define APP_KIND "cpu"
|
||||
|
||||
#define APP_VER_MAJOR 2
|
||||
#define APP_VER_MINOR 4
|
||||
#define APP_VER_BUILD 4
|
||||
#define APP_VER_MINOR 5
|
||||
#define APP_VER_BUILD 0
|
||||
#define APP_VER_REV 0
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -85,7 +86,7 @@ void DoubleWorker::start()
|
|||
*Job::nonce(m_state->blob) = ++m_state->nonce1;
|
||||
*Job::nonce(m_state->blob + m_state->job.size()) = ++m_state->nonce2;
|
||||
|
||||
CryptoNight::hash(m_state->blob, m_state->job.size(), m_hash, m_ctx);
|
||||
CryptoNight::hash(m_state->blob, m_state->job.size(), m_hash, m_ctx, m_state->job.variant());
|
||||
|
||||
if (*reinterpret_cast<uint64_t*>(m_hash + 24) < m_state->job.target()) {
|
||||
Workers::submit(JobResult(m_state->job.poolId(), m_state->job.id(), m_state->nonce1, m_hash, m_state->job.diff()));
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
@ -25,7 +26,6 @@
|
|||
#define __DOUBLEWORKER_H__
|
||||
|
||||
|
||||
#include "align.h"
|
||||
#include "net/Job.h"
|
||||
#include "net/JobResult.h"
|
||||
#include "workers/Worker.h"
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 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
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,13 +21,27 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ALIGN_H__
|
||||
#define __ALIGN_H__
|
||||
#ifndef __XMRIG_H__
|
||||
#define __XMRIG_H__
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define VAR_ALIGN(x, decl) __declspec(align(x)) decl
|
||||
#else
|
||||
# define VAR_ALIGN(x, decl) decl __attribute__ ((aligned(x)))
|
||||
#endif
|
||||
|
||||
#endif /* __ALIGN_H__ */
|
||||
namespace xmrig
|
||||
{
|
||||
|
||||
|
||||
enum Algo {
|
||||
ALGO_CRYPTONIGHT, /* CryptoNight (Monero) */
|
||||
ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
|
||||
};
|
||||
|
||||
|
||||
enum Variant {
|
||||
VARIANT_AUTO = -1,
|
||||
VARIANT_NONE = 0,
|
||||
VARIANT_V1 = 1
|
||||
};
|
||||
|
||||
} /* xmrig */
|
||||
|
||||
|
||||
#endif /* __XMRIG_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue