Skip to content

Commit b313a74

Browse files
committed
Add support for embedded config.
1 parent 44e9b3b commit b313a74

File tree

5 files changed

+105
-4
lines changed

5 files changed

+105
-4
lines changed

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
1414

1515
option(WITH_DEBUG_LOG "Enable debug log output, network, etc" OFF)
1616
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
17+
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
1718

1819
include (CheckIncludeFile)
1920
include (cmake/cpu.cmake)
@@ -76,6 +77,7 @@ set(HEADERS
7677
src/common/utils/mm_malloc.h
7778
src/common/utils/timestamp.h
7879
src/common/xmrig.h
80+
src/core/ConfigLoader_default.h
7981
src/core/ConfigLoader_platform.h
8082
src/core/Controller.h
8183
src/core/usage.h
@@ -265,6 +267,10 @@ if (NOT WITH_CN_PICO)
265267
add_definitions(/DXMRIG_NO_CN_PICO)
266268
endif()
267269

270+
if (WITH_EMBEDDED_CONFIG)
271+
add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG)
272+
endif()
273+
268274
if (WITH_HTTPD)
269275
find_package(MHD)
270276

cmake/cn-gpu.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
44
set(CN_GPU_SOURCES src/crypto/cn_gpu_arm.cpp)
55

66
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
7-
set_source_files_properties(src/crypto/cn_gpu_arm.cpp PROPERTIES COMPILE_FLAGS "-O3")
7+
set_source_files_properties(src/crypto/cn_gpu_arm.cpp PROPERTIES COMPILE_FLAGS "-O2")
88
endif()
99
else()
1010
set(CN_GPU_SOURCES src/crypto/cn_gpu_avx.cpp src/crypto/cn_gpu_ssse3.cpp)
1111

1212
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
13-
set_source_files_properties(src/crypto/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O3 -mavx2")
14-
set_source_files_properties(src/crypto/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O3")
13+
set_source_files_properties(src/crypto/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O2 -mavx2")
14+
set_source_files_properties(src/crypto/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O2")
1515
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
1616
set_source_files_properties(src/crypto/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
1717
endif()

src/common/config/ConfigLoader.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
#include "rapidjson/fwd.h"
5454

5555

56+
#ifdef XMRIG_FEATURE_EMBEDDED_CONFIG
57+
# include "core/ConfigLoader_default.h"
58+
#endif
59+
60+
5661
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
5762
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
5863
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
@@ -180,6 +185,15 @@ xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *crea
180185
loadFromFile(config, process->location(Process::ExeLocation, "config.json"));
181186
}
182187

188+
# ifdef XMRIG_FEATURE_EMBEDDED_CONFIG
189+
if (!config->finalize()) {
190+
delete config;
191+
192+
config = m_creator->create();
193+
loadFromJSON(config, default_config);
194+
}
195+
# endif
196+
183197
if (!config->finalize()) {
184198
if (!config->algorithm().isValid()) {
185199
fprintf(stderr, "No valid algorithm specified. Exiting.\n");

src/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"nicehash": false,
2525
"keepalive": false,
2626
"variant": -1,
27+
"enabled": true,
2728
"tls": false,
2829
"tls-fingerprint": null
2930
}
@@ -34,5 +35,5 @@
3435
"threads": null,
3536
"user-agent": null,
3637
"syslog": false,
37-
"watch": false
38+
"watch": true
3839
}

src/core/ConfigLoader_default.h

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* XMRig
2+
* Copyright 2010 Jeff Garzik <[email protected]>
3+
* Copyright 2012-2014 pooler <[email protected]>
4+
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
5+
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
6+
* Copyright 2016 Jay D Dee <[email protected]>
7+
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
8+
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
9+
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <[email protected]>
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
#ifndef XMRIG_CONFIGLOADER_DEFAULT_H
26+
#define XMRIG_CONFIGLOADER_DEFAULT_H
27+
28+
29+
namespace xmrig {
30+
31+
32+
#ifdef XMRIG_FEATURE_EMBEDDED_CONFIG
33+
const static char *default_config =
34+
R"===(
35+
{
36+
"algo": "cryptonight",
37+
"api": {
38+
"port": 0,
39+
"access-token": null,
40+
"id": null,
41+
"worker-id": null,
42+
"ipv6": false,
43+
"restricted": true
44+
},
45+
"autosave": true,
46+
"background": false,
47+
"cache": true,
48+
"colors": true,
49+
"donate-level": 5,
50+
"log-file": null,
51+
"opencl-platform": "AMD",
52+
"pools": [
53+
{
54+
"url": "donate.v2.xmrig.com:3333",
55+
"user": "YOUR_WALLET_ADDRESS",
56+
"pass": "x",
57+
"rig-id": null,
58+
"nicehash": false,
59+
"keepalive": false,
60+
"variant": -1,
61+
"enabled": true,
62+
"tls": false,
63+
"tls-fingerprint": null
64+
}
65+
],
66+
"print-time": 60,
67+
"retries": 5,
68+
"retry-pause": 5,
69+
"threads": null,
70+
"user-agent": null,
71+
"syslog": false,
72+
"watch": true
73+
}
74+
)===";
75+
#endif
76+
77+
78+
} /* namespace xmrig */
79+
80+
#endif /* XMRIG_CONFIGLOADER_DEFAULT_H */

0 commit comments

Comments
 (0)