Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d696daf5af | ||
|
ac60d9426c | ||
|
209796a07e | ||
|
a1f19305f4 | ||
|
dd3243aa70 | ||
|
09893bfd36 | ||
|
a98c475a3c | ||
|
59b147b6fb | ||
|
17f28667b3 | ||
|
63a62e7ea0 | ||
|
56cacbd5bc | ||
|
8b9d5cff91 | ||
|
eede1b4881 | ||
|
492449e9fb | ||
|
b43336582d | ||
|
67863a427d | ||
|
1382857c83 | ||
|
84c2cadc50 | ||
|
16b4fd0ff5 | ||
|
cfe3995aa8 | ||
|
5382216725 | ||
|
c06f77b9e9 | ||
|
0c930e277b | ||
|
2a2712ab90 | ||
|
9f6f599d78 | ||
|
a76243a65e | ||
|
16babcc6bc | ||
|
3d60b3cc62 | ||
|
acd042c234 | ||
|
a2e384df58 | ||
|
735180ac04 | ||
|
06a84499d7 | ||
|
caa70a1e9d | ||
|
deb832c9c6 | ||
|
d7feb2719e | ||
|
4b91978af6 | ||
|
7e078f2d07 | ||
|
2b0b71b9f6 | ||
|
938e652c45 | ||
|
20bd22ea22 | ||
|
c7c9d20b8b | ||
|
dd6aeb26e8 | ||
|
ba0df6e973 | ||
|
a0f48adf5c | ||
|
2b0cac5d4d | ||
|
afeaabdca4 | ||
|
6b584a78b2 |
@ -1,3 +1,12 @@
|
||||
# v2.9.0
|
||||
- [#899](https://github.com/xmrig/xmrig/issues/899) Added support for new algorithm `cn/half` for Masari and Stellite forks.
|
||||
- [#834](https://github.com/xmrig/xmrig/pull/834) Added ASM optimized code for AMD Bulldozer.
|
||||
- [#839](https://github.com/xmrig/xmrig/issues/839) Fixed FreeBSD compile.
|
||||
- [#857](https://github.com/xmrig/xmrig/pull/857) Fixed impossible to build for macOS without clang.
|
||||
|
||||
# v2.8.3
|
||||
- [#813](https://github.com/xmrig/xmrig/issues/813) Fixed critical bug with Minergate pool and variant 2.
|
||||
|
||||
# v2.8.1
|
||||
- [#768](https://github.com/xmrig/xmrig/issues/768) Fixed build with Visual Studio 2015.
|
||||
- [#769](https://github.com/xmrig/xmrig/issues/769) Fixed regression, some ANSI escape sequences was in log with disabled colors.
|
||||
|
@ -17,6 +17,7 @@ include (cmake/cpu.cmake)
|
||||
set(HEADERS
|
||||
src/api/NetworkState.h
|
||||
src/App.h
|
||||
src/base/tools/String.h
|
||||
src/common/config/CommonConfig.h
|
||||
src/common/config/ConfigLoader.h
|
||||
src/common/config/ConfigWatcher.h
|
||||
@ -93,6 +94,7 @@ endif()
|
||||
set(SOURCES
|
||||
src/api/NetworkState.cpp
|
||||
src/App.cpp
|
||||
src/base/tools/String.cpp
|
||||
src/common/config/CommonConfig.cpp
|
||||
src/common/config/ConfigLoader.cpp
|
||||
src/common/config/ConfigWatcher.cpp
|
||||
@ -155,11 +157,11 @@ else()
|
||||
src/Mem_unix.cpp
|
||||
)
|
||||
|
||||
set(EXTRA_LIBS pthread rt dl)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
set(EXTRA_LIBS ${EXTRA_LIBS} kvm)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
set(EXTRA_LIBS kvm)
|
||||
else()
|
||||
set(EXTRA_LIBS pthread rt dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
@ -255,5 +257,5 @@ if (WITH_DEBUG_LOG)
|
||||
add_definitions(/DAPP_DEBUG)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
|
||||
|
15
README.md
15
README.md
@ -1,7 +1,5 @@
|
||||
# XMRig
|
||||
|
||||
:warning: **[Monero will change PoW algorithm on October 18](https://github.com/xmrig/xmrig/issues/753), all miners and proxy should be updated to [v2.8+](https://github.com/xmrig/xmrig/releases/tag/v2.8.1)** :warning:
|
||||
|
||||
[![Github All Releases](https://img.shields.io/github/downloads/xmrig/xmrig/total.svg)](https://github.com/xmrig/xmrig/releases)
|
||||
[![GitHub release](https://img.shields.io/github/release/xmrig/xmrig/all.svg)](https://github.com/xmrig/xmrig/releases)
|
||||
[![GitHub Release Date](https://img.shields.io/github/release-date-pre/xmrig/xmrig.svg)](https://github.com/xmrig/xmrig/releases)
|
||||
@ -142,19 +140,6 @@ Please note performance is highly dependent on system load. The numbers above ar
|
||||
* XMR: `48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD`
|
||||
* BTC: `1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT`
|
||||
|
||||
## Release checksums
|
||||
### SHA-256
|
||||
```
|
||||
fd909cef75c65c1ee8facd78e968c359e4ac4d2f0b2aaef8c6d3e0138979d0ea xmrig-2.8.1-xenial-amd64.tar.gz/xmrig-2.8.1/xmrig
|
||||
e4987eaec57c1784c423e03978e22262adf070ab3ad7b2a6ce8d0d0626db4cbd xmrig-2.8.1-xenial-amd64.tar.gz/xmrig-2.8.1/xmrig-notls
|
||||
4ebf6053513c8b72b46f54481f33367aae6356fc5f271c9236d708a34cd16e2a xmrig-2.8.1-gcc-win32.zip/xmrig.exe
|
||||
f4ce5b76a611f6768c9a035eae1e49f61666f3e5370b54bd447ecc3b0098efcb xmrig-2.8.1-gcc-win32.zip/xmrig-notls.exe
|
||||
39259979b4228899c0ef985bcfc283e169afd44323eedb0341144dbc0c0f30e9 xmrig-2.8.1-gcc-win64.zip/xmrig.exe
|
||||
68af0f11b29b9b67414d0b661446baa0ad6020598c04c5d0cf24797167753117 xmrig-2.8.1-gcc-win64.zip/xmrig-notls.exe
|
||||
5d8b94157ebb4a7729f0eb8622945c266b756c994c60f91514b329edeb287867 xmrig-2.8.1-msvc-win64.zip/xmrig.exe
|
||||
d97c691d6044f916b9253820832f1a08402bb63aa75fb146ea8c31f51cebe974 xmrig-2.8.1-msvc-win64.zip/xmrig-notls.exe
|
||||
```
|
||||
|
||||
## Contacts
|
||||
* support@xmrig.com
|
||||
* [reddit](https://www.reddit.com/user/XMRig/)
|
||||
|
@ -20,4 +20,6 @@ else()
|
||||
set(TLS_SOURCES "")
|
||||
set(OPENSSL_LIBRARIES "")
|
||||
add_definitions(/DXMRIG_NO_TLS)
|
||||
|
||||
set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls")
|
||||
endif()
|
||||
|
@ -5,9 +5,9 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
enable_language(ASM_MASM)
|
||||
|
||||
if (MSVC_TOOLSET_VERSION GREATER_EQUAL 141)
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cnv2_main_loop.asm")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cn_main_loop.asm")
|
||||
else()
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cnv2_main_loop.asm")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cn_main_loop.asm")
|
||||
endif()
|
||||
|
||||
set_property(SOURCE ${XMRIG_ASM_FILE} PROPERTY ASM_MASM)
|
||||
@ -15,9 +15,9 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
enable_language(ASM)
|
||||
|
||||
if (WIN32 AND CMAKE_C_COMPILER_ID MATCHES GNU)
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cnv2_main_loop.S")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/win64/cn_main_loop.S")
|
||||
else()
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cnv2_main_loop.S")
|
||||
set(XMRIG_ASM_FILE "src/crypto/asm/cn_main_loop.S")
|
||||
endif()
|
||||
|
||||
set_property(SOURCE ${XMRIG_ASM_FILE} PROPERTY C)
|
||||
|
@ -87,6 +87,10 @@ App::~App()
|
||||
|
||||
int App::exec()
|
||||
{
|
||||
if (m_controller->isDone()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!m_controller->isReady()) {
|
||||
return 2;
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
* 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>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
12
src/Mem.h
12
src/Mem.h
@ -6,7 +6,8 @@
|
||||
* 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>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -22,8 +23,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_H__
|
||||
#define __MEM_H__
|
||||
#ifndef XMRIG_MEM_H
|
||||
#define XMRIG_MEM_H
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
@ -59,6 +60,9 @@ public:
|
||||
static void init(bool enabled);
|
||||
static void release(cryptonight_ctx **ctx, size_t count, MemInfo &info);
|
||||
|
||||
static void *allocateExecutableMemory(size_t size);
|
||||
static void flushInstructionCache(void *p, size_t size);
|
||||
|
||||
static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; }
|
||||
|
||||
private:
|
||||
@ -70,4 +74,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif /* __MEM_H__ */
|
||||
#endif /* XMRIG_MEM_H */
|
||||
|
@ -6,7 +6,8 @@
|
||||
* 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>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -87,3 +88,19 @@ void Mem::release(MemInfo &info)
|
||||
_mm_free(info.memory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *Mem::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
# if defined(__APPLE__)
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
# else
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Mem::flushInstructionCache(void *p, size_t size)
|
||||
{
|
||||
__builtin___clear_cache(reinterpret_cast<char*>(p), reinterpret_cast<char*>(p) + size);
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
* 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>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -182,3 +183,15 @@ void Mem::release(MemInfo &info)
|
||||
_mm_free(info.memory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *Mem::allocateExecutableMemory(size_t size)
|
||||
{
|
||||
return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
}
|
||||
|
||||
|
||||
void Mem::flushInstructionCache(void *p, size_t size)
|
||||
{
|
||||
::FlushInstructionCache(GetCurrentProcess(), p, size);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
* 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 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -43,7 +44,8 @@ static const char *coloredAsmNames[] = {
|
||||
"\x1B[1;31mnone\x1B[0m",
|
||||
"auto",
|
||||
"\x1B[1;32mintel\x1B[0m",
|
||||
"\x1B[1;32mryzen\x1B[0m"
|
||||
"\x1B[1;32mryzen\x1B[0m",
|
||||
"\x1B[1;32mbulldozer\x1B[0m"
|
||||
};
|
||||
|
||||
|
||||
|
225
src/base/tools/String.cpp
Normal file
225
src/base/tools/String.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
/* 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 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/tools/String.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
xmrig::String::String(const char *str) :
|
||||
m_data(nullptr),
|
||||
m_size(str == nullptr ? 0 : strlen(str))
|
||||
{
|
||||
if (m_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const char *str, size_t size) :
|
||||
m_data(nullptr),
|
||||
m_size(size)
|
||||
{
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, str, m_size);
|
||||
m_data[m_size] = '\0';
|
||||
}
|
||||
|
||||
|
||||
xmrig::String::String(const String &other) :
|
||||
m_data(nullptr),
|
||||
m_size(other.m_size)
|
||||
{
|
||||
if (other.m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[m_size + 1];
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::String::isEqual(const char *str) const
|
||||
{
|
||||
return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && str == nullptr);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::String::isEqual(const String &other) const
|
||||
{
|
||||
if (m_size != other.m_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (m_data != nullptr && other.m_data != nullptr && memcmp(m_data, other.m_data, m_size) == 0) || (m_data == nullptr && other.m_data == nullptr);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::String::toJSON() const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
return isNull() ? Value(kNullType) : Value(StringRef(m_data));
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::String::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
return isNull() ? Value(kNullType) : Value(m_data, doc.GetAllocator());
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::String> xmrig::String::split(char sep) const
|
||||
{
|
||||
std::vector<xmrig::String> out;
|
||||
if (m_size == 0) {
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
for (pos = 0; pos < m_size; ++pos) {
|
||||
if (m_data[pos] == sep) {
|
||||
if ((pos - start) > 0) {
|
||||
out.push_back(String(m_data + start, pos - start));
|
||||
}
|
||||
|
||||
start = pos + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pos - start) > 0) {
|
||||
out.push_back(String(m_data + start, pos - start));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::String::join(const std::vector<xmrig::String> &vec, char sep)
|
||||
{
|
||||
if (vec.empty()) {
|
||||
return String();
|
||||
}
|
||||
|
||||
size_t size = vec.size();
|
||||
for (const String &str : vec) {
|
||||
size += str.size();
|
||||
}
|
||||
|
||||
size_t offset = 0;
|
||||
char *buf = new char[size];
|
||||
|
||||
for (const String &str : vec) {
|
||||
memcpy(buf + offset, str.data(), str.size());
|
||||
|
||||
offset += str.size() + 1;
|
||||
|
||||
if (offset < size) {
|
||||
buf[offset - 1] = sep;
|
||||
}
|
||||
}
|
||||
|
||||
buf[size - 1] = '\0';
|
||||
|
||||
return String(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::copy(const char *str)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
if (str == nullptr) {
|
||||
m_size = 0;
|
||||
m_data = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_size = strlen(str);
|
||||
m_data = new char[m_size + 1];
|
||||
|
||||
memcpy(m_data, str, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::copy(const String &other)
|
||||
{
|
||||
if (m_size > 0) {
|
||||
if (m_size == other.m_size) {
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
delete [] m_data;
|
||||
|
||||
if (other.m_data == nullptr) {
|
||||
m_size = 0;
|
||||
m_data = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_size = other.m_size;
|
||||
m_data = new char[m_size + 1];
|
||||
|
||||
memcpy(m_data, other.m_data, m_size + 1);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::move(char *str)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
m_size = str == nullptr ? 0 : strlen(str);
|
||||
m_data = str;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::String::move(String &&other)
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
m_data = other.m_data;
|
||||
m_size = other.m_size;
|
||||
|
||||
other.m_data = nullptr;
|
||||
other.m_size = 0;
|
||||
}
|
104
src/base/tools/String.h
Normal file
104
src/base/tools/String.h
Normal file
@ -0,0 +1,104 @@
|
||||
/* 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 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 XMRIG_STRING_H
|
||||
#define XMRIG_STRING_H
|
||||
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Simple C string wrapper.
|
||||
*
|
||||
* 1. I know about std:string.
|
||||
* 2. For some reason I prefer don't use std:string in miner, eg because of file size of MSYS2 builds.
|
||||
* 3. nullptr and JSON conversion supported.
|
||||
*/
|
||||
class String
|
||||
{
|
||||
public:
|
||||
inline String() : m_data(nullptr), m_size(0) {}
|
||||
inline String(char *str) : m_data(str), m_size(str == nullptr ? 0 : strlen(str)) {}
|
||||
inline String(String &&other) : m_data(other.m_data), m_size(other.m_size) { other.m_data = nullptr; other.m_size = 0; }
|
||||
|
||||
String(const char *str);
|
||||
String(const char *str, size_t size);
|
||||
String(const String &other);
|
||||
|
||||
inline ~String() { delete [] m_data; }
|
||||
|
||||
|
||||
bool isEqual(const char *str) const;
|
||||
bool isEqual(const String &other) const;
|
||||
|
||||
|
||||
inline bool contains(const char *str) const { return isNull() ? false : strstr(m_data, str) != nullptr; }
|
||||
|
||||
|
||||
inline bool isEmpty() const { return size() == 0; }
|
||||
inline bool isNull() const { return m_data == nullptr; }
|
||||
inline char *data() { return m_data; }
|
||||
inline const char *data() const { return m_data; }
|
||||
inline size_t size() const { return m_size; }
|
||||
|
||||
|
||||
inline bool operator!=(const char *str) const { return !isEqual(str); }
|
||||
inline bool operator!=(const String &other) const { return !isEqual(other); }
|
||||
inline bool operator<(const String &str) const { return strcmp(data(), str.data()) < 0; }
|
||||
inline bool operator==(const char *str) const { return isEqual(str); }
|
||||
inline bool operator==(const String &other) const { return isEqual(other); }
|
||||
inline operator const char*() const { return m_data; }
|
||||
inline String &operator=(char *str) { move(str); return *this; }
|
||||
inline String &operator=(const char *str) { copy(str); return *this; }
|
||||
inline String &operator=(const String &str) { copy(str); return *this; }
|
||||
inline String &operator=(String &&other) { move(std::move(other)); return *this; }
|
||||
|
||||
rapidjson::Value toJSON() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
std::vector<xmrig::String> split(char sep) const;
|
||||
|
||||
static String join(const std::vector<xmrig::String> &vec, char sep);
|
||||
|
||||
private:
|
||||
void copy(const char *str);
|
||||
void copy(const String &other);
|
||||
void move(char *str);
|
||||
void move(String &&other);
|
||||
|
||||
char *m_data;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_STRING_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 SChernykh <https://github.com/SChernykh>
|
||||
* 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,7 +37,7 @@
|
||||
|
||||
|
||||
char Platform::m_defaultConfigName[520] = { 0 };
|
||||
xmrig::c_str Platform::m_userAgent;
|
||||
xmrig::String Platform::m_userAgent;
|
||||
|
||||
|
||||
const char *Platform::defaultConfigName()
|
||||
|
@ -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 SChernykh <https://github.com/SChernykh>
|
||||
* 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,7 +29,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "common/utils/c_str.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
class Platform
|
||||
@ -36,7 +37,9 @@ class Platform
|
||||
public:
|
||||
static bool setThreadAffinity(uint64_t cpu_id);
|
||||
static const char *defaultConfigName();
|
||||
static uint32_t setTimerResolution(uint32_t resolution);
|
||||
static void init(const char *userAgent);
|
||||
static void restoreTimerResolution();
|
||||
static void setProcessPriority(int priority);
|
||||
static void setThreadPriority(int priority);
|
||||
|
||||
@ -46,7 +49,7 @@ private:
|
||||
static char *createUserAgent();
|
||||
|
||||
static char m_defaultConfigName[520];
|
||||
static xmrig::c_str m_userAgent;
|
||||
static xmrig::String m_userAgent;
|
||||
};
|
||||
|
||||
|
||||
|
@ -40,15 +40,20 @@
|
||||
|
||||
char *Platform::createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s", APP_NAME, APP_VERSION, uv_version_string());
|
||||
|
||||
# ifdef XMRIG_NVIDIA_PROJECT
|
||||
const int cudaVersion = cuda_get_runtime_version();
|
||||
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# else
|
||||
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
|
||||
# endif
|
||||
|
||||
# ifdef __clang__
|
||||
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# endif
|
||||
|
||||
return buf;
|
||||
@ -65,9 +70,19 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
||||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,9 +54,9 @@ typedef cpuset_t cpu_set_t;
|
||||
|
||||
char *Platform::createUserAgent()
|
||||
{
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION);
|
||||
|
||||
# if defined(__x86_64__)
|
||||
@ -70,7 +70,9 @@ char *Platform::createUserAgent()
|
||||
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
|
||||
# endif
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifdef __clang__
|
||||
length += snprintf(buf + length, max - length, " clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# endif
|
||||
|
||||
@ -92,6 +94,17 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
||||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
}
|
||||
|
@ -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 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -22,6 +23,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <uv.h>
|
||||
@ -37,6 +39,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_AMD_PROJECT
|
||||
static uint32_t timerResolution = 0;
|
||||
#endif
|
||||
|
||||
|
||||
static inline OSVERSIONINFOEX winOsVersion()
|
||||
{
|
||||
typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO);
|
||||
@ -58,9 +65,9 @@ static inline OSVERSIONINFOEX winOsVersion()
|
||||
char *Platform::createUserAgent()
|
||||
{
|
||||
const auto osver = winOsVersion();
|
||||
const size_t max = 160;
|
||||
constexpr const size_t max = 256;
|
||||
|
||||
char *buf = new char[max];
|
||||
char *buf = new char[max]();
|
||||
int length = snprintf(buf, max, "%s/%s (Windows NT %lu.%lu", APP_NAME, APP_VERSION, osver.dwMajorVersion, osver.dwMinorVersion);
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64)
|
||||
@ -94,6 +101,34 @@ bool Platform::setThreadAffinity(uint64_t cpu_id)
|
||||
}
|
||||
|
||||
|
||||
uint32_t Platform::setTimerResolution(uint32_t resolution)
|
||||
{
|
||||
# ifdef XMRIG_AMD_PROJECT
|
||||
TIMECAPS tc;
|
||||
|
||||
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
timerResolution = std::min<uint32_t>(std::max<uint32_t>(tc.wPeriodMin, resolution), tc.wPeriodMax);
|
||||
|
||||
return timeBeginPeriod(timerResolution) == TIMERR_NOERROR ? timerResolution : 0;
|
||||
# else
|
||||
return resolution;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Platform::restoreTimerResolution()
|
||||
{
|
||||
# ifdef XMRIG_AMD_PROJECT
|
||||
if (timerResolution) {
|
||||
timeEndPeriod(timerResolution);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void Platform::setProcessPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
@ -121,6 +156,7 @@ void Platform::setProcessPriority(int priority)
|
||||
|
||||
case 5:
|
||||
prio = REALTIME_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -174,8 +174,11 @@ void xmrig::CommonConfig::printVersions()
|
||||
int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
|
||||
# else
|
||||
memset(buf, 0, 16);
|
||||
|
||||
# if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS)
|
||||
int length = 0;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||
{
|
||||
@ -280,16 +283,16 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
|
||||
break;
|
||||
|
||||
case KeepAliveKey: /* --keepalive */
|
||||
m_pools.back().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
|
||||
currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
|
||||
break;
|
||||
|
||||
case TlsKey: /* --tls */
|
||||
m_pools.back().setTLS(enable);
|
||||
currentPool().setTLS(enable);
|
||||
break;
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
case NicehashKey: /* --nicehash */
|
||||
m_pools.back().setNicehash(enable);
|
||||
currentPool().setNicehash(enable);
|
||||
break;
|
||||
# endif
|
||||
|
||||
@ -333,13 +336,15 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
||||
break;
|
||||
|
||||
case UserpassKey: /* --userpass */
|
||||
if (!m_pools.back().setUserpass(arg)) {
|
||||
if (!currentPool().setUserpass(arg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UrlKey: /* --url */
|
||||
fixup();
|
||||
|
||||
if (m_pools.size() > 1 || m_pools[0].isValid()) {
|
||||
Pool pool(arg);
|
||||
|
||||
@ -358,23 +363,23 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
||||
break;
|
||||
|
||||
case UserKey: /* --user */
|
||||
m_pools.back().setUser(arg);
|
||||
currentPool().setUser(arg);
|
||||
break;
|
||||
|
||||
case PasswordKey: /* --pass */
|
||||
m_pools.back().setPassword(arg);
|
||||
currentPool().setPassword(arg);
|
||||
break;
|
||||
|
||||
case RigIdKey: /* --rig-id */
|
||||
m_pools.back().setRigId(arg);
|
||||
currentPool().setRigId(arg);
|
||||
break;
|
||||
|
||||
case FingerprintKey: /* --tls-fingerprint */
|
||||
m_pools.back().setFingerprint(arg);
|
||||
currentPool().setFingerprint(arg);
|
||||
break;
|
||||
|
||||
case VariantKey: /* --variant */
|
||||
m_pools.back().algorithm().parseVariant(arg);
|
||||
currentPool().algorithm().parseVariant(arg);
|
||||
break;
|
||||
|
||||
case LogFileKey: /* --log-file */
|
||||
@ -400,7 +405,7 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
|
||||
case RetriesKey: /* --retries */
|
||||
case RetryPauseKey: /* --retry-pause */
|
||||
case ApiPort: /* --api-port */
|
||||
case PrintTimeKey: /* --cpu-priority */
|
||||
case PrintTimeKey: /* --print-time */
|
||||
return parseUint64(key, strtol(arg, nullptr, 10));
|
||||
|
||||
case BackgroundKey: /* --background */
|
||||
@ -462,11 +467,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
||||
break;
|
||||
|
||||
case KeepAliveKey: /* --keepalive */
|
||||
m_pools.back().setKeepAlive(arg);
|
||||
currentPool().setKeepAlive(arg);
|
||||
break;
|
||||
|
||||
case VariantKey: /* --variant */
|
||||
m_pools.back().algorithm().parseVariant(arg);
|
||||
currentPool().algorithm().parseVariant(arg);
|
||||
break;
|
||||
|
||||
case DonateLevelKey: /* --donate-level */
|
||||
@ -493,3 +498,30 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Pool &xmrig::CommonConfig::currentPool()
|
||||
{
|
||||
fixup();
|
||||
|
||||
return m_pools.back();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CommonConfig::fixup()
|
||||
{
|
||||
if (m_state == NoneState) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pools.empty()) {
|
||||
if (!m_activePools.empty()) {
|
||||
std::swap(m_pools, m_activePools);
|
||||
}
|
||||
else {
|
||||
m_pools.push_back(Pool());
|
||||
}
|
||||
|
||||
m_state = NoneState;
|
||||
}
|
||||
}
|
||||
|
@ -112,9 +112,11 @@ protected:
|
||||
|
||||
private:
|
||||
bool parseInt(int key, int arg);
|
||||
Pool ¤tPool();
|
||||
void fixup();
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __COMMONCONFIG_H__ */
|
||||
#endif /* XMRIG_COMMONCONFIG_H */
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -50,6 +50,7 @@
|
||||
#include "rapidjson/filereadstream.h"
|
||||
|
||||
|
||||
bool xmrig::ConfigLoader::m_done = false;
|
||||
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
|
||||
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
|
||||
xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr;
|
||||
@ -283,12 +284,16 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option
|
||||
|
||||
void xmrig::ConfigLoader::showUsage()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(usage);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ConfigLoader::showVersion()
|
||||
{
|
||||
m_done = true;
|
||||
|
||||
printf(APP_NAME " " APP_VERSION "\n built on " __DATE__
|
||||
|
||||
# if defined(__clang__)
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,8 +21,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIGLOADER_H__
|
||||
#define __CONFIGLOADER_H__
|
||||
#ifndef XMRIG_CONFIGLOADER_H
|
||||
#define XMRIG_CONFIGLOADER_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
@ -53,6 +53,8 @@ public:
|
||||
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener);
|
||||
static void release();
|
||||
|
||||
static inline bool isDone() { return m_done; }
|
||||
|
||||
private:
|
||||
static bool getJSON(const char *fileName, rapidjson::Document &doc);
|
||||
static bool parseArg(IConfig *config, int key, const char *arg);
|
||||
@ -60,6 +62,7 @@ private:
|
||||
static void showUsage();
|
||||
static void showVersion();
|
||||
|
||||
static bool m_done;
|
||||
static ConfigWatcher *m_watcher;
|
||||
static IConfigCreator *m_creator;
|
||||
static IWatcherListener *m_listener;
|
||||
@ -68,4 +71,4 @@ private:
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
#endif /* __CONFIGLOADER_H__ */
|
||||
#endif /* XMRIG_CONFIGLOADER_H */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -62,6 +62,8 @@ static AlgoData const algorithms[] = {
|
||||
{ "cryptonight/xao", "cn/xao", xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO },
|
||||
{ "cryptonight/rto", "cn/rto", xmrig::CRYPTONIGHT, xmrig::VARIANT_RTO },
|
||||
{ "cryptonight/2", "cn/2", xmrig::CRYPTONIGHT, xmrig::VARIANT_2 },
|
||||
{ "cryptonight/half", "cn/half", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
|
||||
{ "cryptonight/xtlv9", "cn/xtlv9", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
||||
@ -109,9 +111,13 @@ static const char *variants[] = {
|
||||
"xao",
|
||||
"rto",
|
||||
"2",
|
||||
"half"
|
||||
};
|
||||
|
||||
|
||||
static_assert(xmrig::VARIANT_MAX == ARRAY_SIZE(variants), "variants size mismatch");
|
||||
|
||||
|
||||
bool xmrig::Algorithm::isValid() const
|
||||
{
|
||||
if (m_algo == INVALID_ALGO) {
|
||||
@ -144,10 +150,16 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
|
||||
m_variant = VARIANT_AUTO;
|
||||
|
||||
assert(algo != nullptr);
|
||||
if (algo == nullptr) {
|
||||
if (algo == nullptr || strlen(algo) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (*algo == '!') {
|
||||
m_flags |= Forced;
|
||||
|
||||
return parseAlgorithm(algo + 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
|
||||
if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) {
|
||||
m_algo = algorithms[i].algo;
|
||||
@ -166,12 +178,26 @@ void xmrig::Algorithm::parseVariant(const char *variant)
|
||||
{
|
||||
m_variant = VARIANT_AUTO;
|
||||
|
||||
if (variant == nullptr || strlen(variant) < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (*variant == '!') {
|
||||
m_flags |= Forced;
|
||||
|
||||
return parseVariant(variant + 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
|
||||
if (strcasecmp(variant, variants[i]) == 0) {
|
||||
m_variant = static_cast<Variant>(i);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp(variant, "xtlv9") == 0) {
|
||||
m_variant = VARIANT_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -39,28 +39,38 @@ namespace xmrig {
|
||||
class Algorithm
|
||||
{
|
||||
public:
|
||||
enum Flags {
|
||||
None = 0,
|
||||
Forced = 1
|
||||
};
|
||||
|
||||
inline Algorithm() :
|
||||
m_algo(INVALID_ALGO),
|
||||
m_flags(0),
|
||||
m_variant(VARIANT_AUTO)
|
||||
{}
|
||||
|
||||
inline Algorithm(Algo algo, Variant variant) :
|
||||
m_flags(0),
|
||||
m_variant(variant)
|
||||
{
|
||||
setAlgo(algo);
|
||||
}
|
||||
|
||||
inline Algorithm(const char *algo)
|
||||
inline Algorithm(const char *algo) :
|
||||
m_flags(0)
|
||||
{
|
||||
parseAlgorithm(algo);
|
||||
}
|
||||
|
||||
bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
|
||||
inline Algo algo() const { return m_algo; }
|
||||
inline const char *name() const { return name(false); }
|
||||
inline const char *shortName() const { return name(true); }
|
||||
inline Variant variant() const { return m_variant; }
|
||||
inline void setVariant(Variant variant) { m_variant = variant; }
|
||||
inline Algo algo() const { return m_algo; }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
|
||||
inline bool isForced() const { return m_flags & Forced; }
|
||||
inline const char *name() const { return name(false); }
|
||||
inline const char *shortName() const { return name(true); }
|
||||
inline int flags() const { return m_flags; }
|
||||
inline Variant variant() const { return m_variant; }
|
||||
inline void setVariant(Variant variant) { m_variant = variant; }
|
||||
|
||||
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
|
||||
@ -80,6 +90,7 @@ private:
|
||||
const char *name(bool shortName) const;
|
||||
|
||||
Algo m_algo;
|
||||
int m_flags;
|
||||
Variant m_variant;
|
||||
};
|
||||
|
||||
|
@ -97,16 +97,23 @@ public:
|
||||
OclCompModeKey = 1410,
|
||||
|
||||
// xmrig-proxy
|
||||
AccessLogFileKey = 'A',
|
||||
BindKey = 'b',
|
||||
CoinKey = 1104,
|
||||
CustomDiffKey = 1102,
|
||||
DebugKey = 1101,
|
||||
ModeKey = 'm',
|
||||
PoolCoinKey = 'C',
|
||||
ReuseTimeoutKey = 1106,
|
||||
WorkersKey = 1103,
|
||||
WorkersAdvKey = 1107,
|
||||
AccessLogFileKey = 'A',
|
||||
BindKey = 'b',
|
||||
CoinKey = 1104,
|
||||
CustomDiffKey = 1102,
|
||||
DebugKey = 1101,
|
||||
ModeKey = 'm',
|
||||
PoolCoinKey = 'C',
|
||||
ReuseTimeoutKey = 1106,
|
||||
WorkersKey = 1103,
|
||||
WorkersAdvKey = 1107,
|
||||
TlsBindKey = 1108,
|
||||
TlsCertKey = 1109,
|
||||
TlsCertKeyKey = 1110,
|
||||
TlsDHparamKey = 1111,
|
||||
TlsCiphersKey = 1112,
|
||||
TlsCipherSuitesKey = 1113,
|
||||
TlsProtocolsKey = 1114,
|
||||
|
||||
// xmrig nvidia
|
||||
CudaMaxThreadsKey = 1200,
|
||||
|
@ -21,8 +21,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
#ifndef XMRIG_LOG_H
|
||||
#define XMRIG_LOG_H
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
@ -39,7 +39,7 @@ public:
|
||||
static inline Log* i() { if (!m_self) { defaultInit(); } return m_self; }
|
||||
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
|
||||
static inline void init() { if (!m_self) { new Log(); } }
|
||||
static inline void release() { assert(m_self != nullptr); delete m_self; }
|
||||
static inline void release() { delete m_self; }
|
||||
|
||||
void message(ILogBackend::Level level, const char* fmt, ...);
|
||||
void text(const char* fmt, ...);
|
||||
@ -98,4 +98,4 @@ private:
|
||||
# define LOG_DEBUG_WARN(x, ...)
|
||||
#endif
|
||||
|
||||
#endif /* __LOG_H__ */
|
||||
#endif /* XMRIG_LOG_H */
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -212,6 +212,12 @@ const char *Client::tlsVersion() const
|
||||
|
||||
int64_t Client::submit(const JobResult &result)
|
||||
{
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
if (result.clientId != m_rpcId) {
|
||||
return -1;
|
||||
}
|
||||
# endif
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
@ -336,8 +342,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
if (params.HasMember("algo")) {
|
||||
job.setAlgorithm(params["algo"].GetString());
|
||||
}
|
||||
|
||||
if (params.HasMember("variant")) {
|
||||
else if (params.HasMember("variant")) {
|
||||
const rapidjson::Value &variant = params["variant"];
|
||||
|
||||
if (variant.IsInt()) {
|
||||
@ -355,6 +360,8 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_job.setClientId(m_rpcId);
|
||||
|
||||
if (m_job != job) {
|
||||
m_jobs++;
|
||||
m_job = std::move(job);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,8 +21,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ID_H__
|
||||
#define __ID_H__
|
||||
#ifndef XMRIG_ID_H
|
||||
#define XMRIG_ID_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
@ -95,4 +95,4 @@ private:
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* __ID_H__ */
|
||||
#endif /* XMRIG_ID_H */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -91,6 +91,12 @@ Job::~Job()
|
||||
}
|
||||
|
||||
|
||||
bool Job::isEqual(const Job &other) const
|
||||
{
|
||||
return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool Job::setBlob(const char *blob)
|
||||
{
|
||||
if (!blob) {
|
||||
@ -119,6 +125,15 @@ bool Job::setBlob(const char *blob)
|
||||
m_algorithm.setVariant(variant());
|
||||
}
|
||||
|
||||
if (!m_algorithm.isForced()) {
|
||||
if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
}
|
||||
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) {
|
||||
m_algorithm.setVariant(xmrig::VARIANT_HALF);
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
memset(m_rawBlob, 0, sizeof(m_rawBlob));
|
||||
memcpy(m_rawBlob, blob, m_size * 2);
|
||||
@ -214,18 +229,6 @@ char *Job::toHex(const unsigned char* in, unsigned int len)
|
||||
#endif
|
||||
|
||||
|
||||
bool Job::operator==(const Job &other) const
|
||||
{
|
||||
return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool Job::operator!=(const Job &other) const
|
||||
{
|
||||
return m_id != other.m_id || memcmp(m_blob, other.m_blob, sizeof(m_blob)) != 0;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Variant Job::variant() const
|
||||
{
|
||||
using namespace xmrig;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user