diff --git a/src/App.cpp b/src/App.cpp index 106238c8..f57e658f 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -32,7 +32,7 @@ #include "backend/cpu/Cpu.h" #include "base/io/Console.h" #include "base/io/log/Log.h" -#include "base/kernel/Signals.h" +#include "base/io/Signals.h" #include "base/kernel/Platform.h" #include "core/config/Config.h" #include "core/Controller.h" diff --git a/src/backend/common/Hashrate.cpp b/src/backend/common/Hashrate.cpp index eb01a5fb..c7ef90fb 100644 --- a/src/backend/common/Hashrate.cpp +++ b/src/backend/common/Hashrate.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -30,10 +30,10 @@ #include "backend/common/Hashrate.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" #include "base/tools/Chrono.h" #include "base/tools/Handle.h" -#include "rapidjson/document.h" inline static const char *format(double h, char *buf, size_t size) diff --git a/src/backend/common/Hashrate.h b/src/backend/common/Hashrate.h index ba60d2ad..59e1afe1 100644 --- a/src/backend/common/Hashrate.h +++ b/src/backend/common/Hashrate.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -30,8 +30,8 @@ #include +#include "3rdparty/rapidjson/fwd.h" #include "base/tools/Object.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/backend/common/Threads.cpp b/src/backend/common/Threads.cpp index 4b23e85d..920e7def 100644 --- a/src/backend/common/Threads.cpp +++ b/src/backend/common/Threads.cpp @@ -24,9 +24,9 @@ #include "backend/common/Threads.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cpu/CpuThreads.h" #include "crypto/cn/CnAlgo.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_OPENCL diff --git a/src/backend/common/Threads.h b/src/backend/common/Threads.h index a21fe13b..1682efba 100644 --- a/src/backend/common/Threads.h +++ b/src/backend/common/Threads.h @@ -30,9 +30,9 @@ #include +#include "3rdparty/rapidjson/fwd.h" #include "base/crypto/Algorithm.h" #include "base/tools/String.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/backend/common/common.cmake b/src/backend/common/common.cmake index 9dd0fb3c..03c37c8f 100644 --- a/src/backend/common/common.cmake +++ b/src/backend/common/common.cmake @@ -4,7 +4,6 @@ set(HEADERS_BACKEND_COMMON src/backend/common/interfaces/IBackend.h src/backend/common/interfaces/IRxListener.h src/backend/common/interfaces/IRxStorage.h - src/backend/common/interfaces/IThread.h src/backend/common/interfaces/IWorker.h src/backend/common/misc/PciTopology.h src/backend/common/Thread.h diff --git a/src/backend/common/interfaces/IBackend.h b/src/backend/common/interfaces/IBackend.h index bdaf5463..405d876a 100644 --- a/src/backend/common/interfaces/IBackend.h +++ b/src/backend/common/interfaces/IBackend.h @@ -29,7 +29,7 @@ #include -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/backend/common/interfaces/IThread.h b/src/backend/common/interfaces/IThread.h deleted file mode 100644 index 3c0a7287..00000000 --- a/src/backend/common/interfaces/IThread.h +++ /dev/null @@ -1,77 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2016-2018 XMRig - * - * 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 . - */ - -#ifndef XMRIG_ITHREAD_H -#define XMRIG_ITHREAD_H - - -#include - - -#include "crypto/common/Algorithm.h" -#include "rapidjson/fwd.h" - - -namespace xmrig { - - -class IThread -{ -public: - enum Type { - CPU, - OpenCL, - CUDA - }; - - enum Multiway { - SingleWay = 1, - DoubleWay, - TripleWay, - QuadWay, - PentaWay - }; - - virtual ~IThread() = default; - - virtual Algorithm algorithm() const = 0; - virtual int priority() const = 0; - virtual int64_t affinity() const = 0; - virtual Multiway multiway() const = 0; - virtual rapidjson::Value toConfig(rapidjson::Document &doc) const = 0; - virtual size_t index() const = 0; - virtual Type type() const = 0; - -# ifdef XMRIG_FEATURE_API - virtual rapidjson::Value toAPI(rapidjson::Document &doc) const = 0; -# endif - -# ifdef APP_DEBUG - virtual void print() const = 0; -# endif -}; - - -} /* namespace xmrig */ - - -#endif // XMRIG_ITHREAD_H diff --git a/src/backend/cpu/Cpu.cpp b/src/backend/cpu/Cpu.cpp index 1e315777..a11c4c56 100644 --- a/src/backend/cpu/Cpu.cpp +++ b/src/backend/cpu/Cpu.cpp @@ -27,7 +27,7 @@ #include "backend/cpu/Cpu.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" #if defined(XMRIG_FEATURE_HWLOC) diff --git a/src/backend/cpu/CpuBackend.cpp b/src/backend/cpu/CpuBackend.cpp index 1efc1eaf..40b774d2 100644 --- a/src/backend/cpu/CpuBackend.cpp +++ b/src/backend/cpu/CpuBackend.cpp @@ -26,12 +26,13 @@ #include +#include "backend/cpu/CpuBackend.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Hashrate.h" #include "backend/common/interfaces/IWorker.h" #include "backend/common/Tags.h" #include "backend/common/Workers.h" #include "backend/cpu/Cpu.h" -#include "backend/cpu/CpuBackend.h" #include "base/io/log/Log.h" #include "base/net/stratum/Job.h" #include "base/tools/Chrono.h" @@ -41,7 +42,6 @@ #include "crypto/common/VirtualMemory.h" #include "crypto/rx/Rx.h" #include "crypto/rx/RxDataset.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_API diff --git a/src/backend/cpu/CpuConfig.cpp b/src/backend/cpu/CpuConfig.cpp index 4c7a630f..ab966e70 100644 --- a/src/backend/cpu/CpuConfig.cpp +++ b/src/backend/cpu/CpuConfig.cpp @@ -24,10 +24,10 @@ #include "backend/cpu/CpuConfig.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cpu/CpuConfig_gen.h" #include "backend/cpu/Cpu.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" #include diff --git a/src/backend/cpu/CpuThread.cpp b/src/backend/cpu/CpuThread.cpp index 660107fa..4da1baf7 100644 --- a/src/backend/cpu/CpuThread.cpp +++ b/src/backend/cpu/CpuThread.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,8 +24,8 @@ #include "backend/cpu/CpuThread.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" xmrig::CpuThread::CpuThread(const rapidjson::Value &value) diff --git a/src/backend/cpu/CpuThread.h b/src/backend/cpu/CpuThread.h index 91d63a1c..b198c800 100644 --- a/src/backend/cpu/CpuThread.h +++ b/src/backend/cpu/CpuThread.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,7 +26,7 @@ #define XMRIG_CPUTHREAD_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/backend/cpu/CpuThreads.cpp b/src/backend/cpu/CpuThreads.cpp index 416b4ecb..d9ae61b1 100644 --- a/src/backend/cpu/CpuThreads.cpp +++ b/src/backend/cpu/CpuThreads.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,8 @@ #include "backend/cpu/CpuThreads.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/backend/cpu/CpuThreads.h b/src/backend/cpu/CpuThreads.h index 076670cd..e87f5230 100644 --- a/src/backend/cpu/CpuThreads.h +++ b/src/backend/cpu/CpuThreads.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/cuda/CudaBackend.cpp b/src/backend/cuda/CudaBackend.cpp index 25a77336..6004a83d 100644 --- a/src/backend/cuda/CudaBackend.cpp +++ b/src/backend/cuda/CudaBackend.cpp @@ -28,6 +28,7 @@ #include "backend/cuda/CudaBackend.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Hashrate.h" #include "backend/common/interfaces/IWorker.h" #include "backend/common/Tags.h" @@ -43,7 +44,6 @@ #include "base/tools/String.h" #include "core/config/Config.h" #include "core/Controller.h" -#include "rapidjson/document.h" #ifdef XMRIG_ALGO_ASTROBWT diff --git a/src/backend/cuda/CudaConfig.cpp b/src/backend/cuda/CudaConfig.cpp index 618aefa9..89e5237e 100644 --- a/src/backend/cuda/CudaConfig.cpp +++ b/src/backend/cuda/CudaConfig.cpp @@ -24,12 +24,12 @@ #include "backend/cuda/CudaConfig.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Tags.h" #include "backend/cuda/CudaConfig_gen.h" #include "backend/cuda/wrappers/CudaLib.h" #include "base/io/json/Json.h" #include "base/io/log/Log.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/backend/cuda/CudaThread.cpp b/src/backend/cuda/CudaThread.cpp index eb65dc2c..fff58eaa 100644 --- a/src/backend/cuda/CudaThread.cpp +++ b/src/backend/cuda/CudaThread.cpp @@ -24,9 +24,9 @@ #include "backend/cuda/CudaThread.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cuda/wrappers/CudaLib.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" #include diff --git a/src/backend/cuda/CudaThread.h b/src/backend/cuda/CudaThread.h index 3588e846..75110bfd 100644 --- a/src/backend/cuda/CudaThread.h +++ b/src/backend/cuda/CudaThread.h @@ -29,7 +29,7 @@ using nvid_ctx = struct nvid_ctx; -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/backend/cuda/CudaThreads.cpp b/src/backend/cuda/CudaThreads.cpp index 5ff4cb24..b5696350 100644 --- a/src/backend/cuda/CudaThreads.cpp +++ b/src/backend/cuda/CudaThreads.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,8 +24,8 @@ #include "backend/cuda/CudaThreads.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" #include diff --git a/src/backend/cuda/CudaThreads.h b/src/backend/cuda/CudaThreads.h index 5f174d8e..eb6d54ee 100644 --- a/src/backend/cuda/CudaThreads.h +++ b/src/backend/cuda/CudaThreads.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/cuda/wrappers/CudaDevice.cpp b/src/backend/cuda/wrappers/CudaDevice.cpp index daa16074..f06fe940 100644 --- a/src/backend/cuda/wrappers/CudaDevice.cpp +++ b/src/backend/cuda/wrappers/CudaDevice.cpp @@ -24,11 +24,12 @@ #include "backend/cuda/wrappers/CudaDevice.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cuda/CudaThreads.h" #include "backend/cuda/wrappers/CudaLib.h" #include "base/crypto/Algorithm.h" #include "base/io/log/Log.h" -#include "rapidjson/document.h" + #ifdef XMRIG_FEATURE_NVML # include "backend/cuda/wrappers/NvmlLib.h" diff --git a/src/backend/cuda/wrappers/CudaLib.cpp b/src/backend/cuda/wrappers/CudaLib.cpp index db1ff904..9436f760 100644 --- a/src/backend/cuda/wrappers/CudaLib.cpp +++ b/src/backend/cuda/wrappers/CudaLib.cpp @@ -28,7 +28,7 @@ #include "backend/cuda/wrappers/CudaLib.h" -#include "base/kernel/Env.h" +#include "base/io/Env.h" #include "crypto/rx/RxAlgo.h" diff --git a/src/backend/opencl/OclBackend.cpp b/src/backend/opencl/OclBackend.cpp index 4b1a14bc..2d431c32 100644 --- a/src/backend/opencl/OclBackend.cpp +++ b/src/backend/opencl/OclBackend.cpp @@ -28,6 +28,7 @@ #include "backend/opencl/OclBackend.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Hashrate.h" #include "backend/common/interfaces/IWorker.h" #include "backend/common/Tags.h" @@ -45,7 +46,6 @@ #include "base/tools/String.h" #include "core/config/Config.h" #include "core/Controller.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_API diff --git a/src/backend/opencl/OclConfig.cpp b/src/backend/opencl/OclConfig.cpp index b06746f3..c05f36d4 100644 --- a/src/backend/opencl/OclConfig.cpp +++ b/src/backend/opencl/OclConfig.cpp @@ -24,12 +24,12 @@ #include "backend/opencl/OclConfig.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Tags.h" #include "backend/opencl/OclConfig_gen.h" #include "backend/opencl/wrappers/OclLib.h" #include "base/io/json/Json.h" #include "base/io/log/Log.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/backend/opencl/OclThread.cpp b/src/backend/opencl/OclThread.cpp index b542b443..087b2cf7 100644 --- a/src/backend/opencl/OclThread.cpp +++ b/src/backend/opencl/OclThread.cpp @@ -24,8 +24,8 @@ #include "backend/opencl/OclThread.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" #include diff --git a/src/backend/opencl/OclThread.h b/src/backend/opencl/OclThread.h index dac57a4f..fbdfe177 100644 --- a/src/backend/opencl/OclThread.h +++ b/src/backend/opencl/OclThread.h @@ -26,7 +26,7 @@ #define XMRIG_OCLTHREAD_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" #include diff --git a/src/backend/opencl/OclThreads.cpp b/src/backend/opencl/OclThreads.cpp index 3e53a5f5..5b699513 100644 --- a/src/backend/opencl/OclThreads.cpp +++ b/src/backend/opencl/OclThreads.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,8 @@ #include "backend/opencl/OclThreads.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" xmrig::OclThreads::OclThreads(const rapidjson::Value &value) diff --git a/src/backend/opencl/OclThreads.h b/src/backend/opencl/OclThreads.h index ed3ad18d..8d9c101e 100644 --- a/src/backend/opencl/OclThreads.h +++ b/src/backend/opencl/OclThreads.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/opencl/wrappers/OclDevice.cpp b/src/backend/opencl/wrappers/OclDevice.cpp index cd90e95b..68ab6072 100644 --- a/src/backend/opencl/wrappers/OclDevice.cpp +++ b/src/backend/opencl/wrappers/OclDevice.cpp @@ -24,11 +24,12 @@ #include "backend/opencl/wrappers/OclDevice.h" +#include "3rdparty/rapidjson/document.h" #include "backend/opencl/OclGenerator.h" #include "backend/opencl/OclThreads.h" #include "backend/opencl/wrappers/OclLib.h" #include "base/io/log/Log.h" -#include "rapidjson/document.h" + #ifdef XMRIG_FEATURE_ADL # include "backend/opencl/wrappers/AdlLib.h" diff --git a/src/backend/opencl/wrappers/OclLib.cpp b/src/backend/opencl/wrappers/OclLib.cpp index d3329e73..b5b12c62 100644 --- a/src/backend/opencl/wrappers/OclLib.cpp +++ b/src/backend/opencl/wrappers/OclLib.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -31,8 +31,8 @@ #include "backend/opencl/wrappers/OclLib.h" #include "backend/common/Tags.h" #include "backend/opencl/wrappers/OclError.h" +#include "base/io/Env.h" #include "base/io/log/Log.h" -#include "base/kernel/Env.h" #if defined(OCL_DEBUG_REFERENCE_COUNT) diff --git a/src/backend/opencl/wrappers/OclLib.h b/src/backend/opencl/wrappers/OclLib.h index 9b9e19a8..b4db1d8d 100644 --- a/src/backend/opencl/wrappers/OclLib.h +++ b/src/backend/opencl/wrappers/OclLib.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/opencl/wrappers/OclPlatform.cpp b/src/backend/opencl/wrappers/OclPlatform.cpp index 601ee6fa..6c3509f0 100644 --- a/src/backend/opencl/wrappers/OclPlatform.cpp +++ b/src/backend/opencl/wrappers/OclPlatform.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -23,9 +23,9 @@ */ -#include "backend/opencl/wrappers/OclLib.h" #include "backend/opencl/wrappers/OclPlatform.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" +#include "backend/opencl/wrappers/OclLib.h" std::vector xmrig::OclPlatform::get() diff --git a/src/backend/opencl/wrappers/OclPlatform.h b/src/backend/opencl/wrappers/OclPlatform.h index 133e8475..dc9bd24e 100644 --- a/src/backend/opencl/wrappers/OclPlatform.h +++ b/src/backend/opencl/wrappers/OclPlatform.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/base/api/Api.cpp b/src/base/api/Api.cpp index 535875fb..85c9dd60 100644 --- a/src/base/api/Api.cpp +++ b/src/base/api/Api.cpp @@ -31,9 +31,9 @@ #include "base/api/interfaces/IApiListener.h" #include "base/api/requests/HttpApiRequest.h" #include "base/crypto/keccak.h" +#include "base/io/Env.h" #include "base/io/json/Json.h" #include "base/kernel/Base.h" -#include "base/kernel/Env.h" #include "base/tools/Buffer.h" #include "base/tools/Chrono.h" #include "core/config/Config.h" diff --git a/src/base/api/interfaces/IApiRequest.h b/src/base/api/interfaces/IApiRequest.h index c23c1652..c05e513e 100644 --- a/src/base/api/interfaces/IApiRequest.h +++ b/src/base/api/interfaces/IApiRequest.h @@ -26,7 +26,7 @@ #define XMRIG_IAPIREQUEST_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/api/requests/HttpApiRequest.cpp b/src/base/api/requests/HttpApiRequest.cpp index 6be25e96..70fa2523 100644 --- a/src/base/api/requests/HttpApiRequest.cpp +++ b/src/base/api/requests/HttpApiRequest.cpp @@ -23,11 +23,11 @@ */ -#include "3rdparty/http-parser/http_parser.h" #include "base/api/requests/HttpApiRequest.h" +#include "3rdparty/http-parser/http_parser.h" +#include "3rdparty/rapidjson/error/en.h" #include "base/io/json/Json.h" #include "base/net/http/HttpData.h" -#include "rapidjson/error/en.h" namespace xmrig { diff --git a/src/base/base.cmake b/src/base/base.cmake index d32f723e..2957a565 100644 --- a/src/base/base.cmake +++ b/src/base/base.cmake @@ -4,6 +4,7 @@ set(HEADERS_BASE src/base/crypto/Coin.h src/base/crypto/keccak.h src/base/io/Console.h + src/base/io/Env.h src/base/io/json/Json.h src/base/io/json/JsonChain.h src/base/io/json/JsonRequest.h @@ -11,12 +12,12 @@ set(HEADERS_BASE src/base/io/log/backends/FileLog.h src/base/io/log/FileLogWriter.h src/base/io/log/Log.h + src/base/io/Signals.h src/base/io/Watcher.h src/base/kernel/Base.h src/base/kernel/config/BaseConfig.h src/base/kernel/config/BaseTransform.h src/base/kernel/Entry.h - src/base/kernel/Env.h src/base/kernel/interfaces/IBaseListener.h src/base/kernel/interfaces/IClient.h src/base/kernel/interfaces/IClientListener.h @@ -34,7 +35,6 @@ set(HEADERS_BASE src/base/kernel/interfaces/IWatcherListener.h src/base/kernel/Platform.h src/base/kernel/Process.h - src/base/kernel/Signals.h src/base/net/dns/Dns.h src/base/net/dns/DnsRecord.h src/base/net/http/Http.h @@ -70,6 +70,7 @@ set(SOURCES_BASE src/base/crypto/Coin.cpp src/base/crypto/keccak.cpp src/base/io/Console.cpp + src/base/io/Env.cpp src/base/io/json/Json.cpp src/base/io/json/JsonChain.cpp src/base/io/json/JsonRequest.cpp @@ -77,15 +78,14 @@ set(SOURCES_BASE src/base/io/log/backends/FileLog.cpp src/base/io/log/FileLogWriter.cpp src/base/io/log/Log.cpp + src/base/io/Signals.cpp src/base/io/Watcher.cpp src/base/kernel/Base.cpp src/base/kernel/config/BaseConfig.cpp src/base/kernel/config/BaseTransform.cpp src/base/kernel/Entry.cpp - src/base/kernel/Env.cpp src/base/kernel/Platform.cpp src/base/kernel/Process.cpp - src/base/kernel/Signals.cpp src/base/net/dns/Dns.cpp src/base/net/dns/DnsRecord.cpp src/base/net/http/Http.cpp diff --git a/src/base/crypto/Algorithm.cpp b/src/base/crypto/Algorithm.cpp index 5ed37219..7d7db9b4 100644 --- a/src/base/crypto/Algorithm.cpp +++ b/src/base/crypto/Algorithm.cpp @@ -25,7 +25,7 @@ #include "base/crypto/Algorithm.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" #include diff --git a/src/base/crypto/Algorithm.h b/src/base/crypto/Algorithm.h index 198ca4f2..1fb9e2ac 100644 --- a/src/base/crypto/Algorithm.h +++ b/src/base/crypto/Algorithm.h @@ -30,7 +30,7 @@ #include -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/crypto/Coin.cpp b/src/base/crypto/Coin.cpp index 8b32e4fc..57b5fcf0 100644 --- a/src/base/crypto/Coin.cpp +++ b/src/base/crypto/Coin.cpp @@ -25,7 +25,7 @@ #include "base/crypto/Coin.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" #include diff --git a/src/base/crypto/Coin.h b/src/base/crypto/Coin.h index 3197c46d..73eb8d24 100644 --- a/src/base/crypto/Coin.h +++ b/src/base/crypto/Coin.h @@ -27,8 +27,8 @@ #define XMRIG_COIN_H +#include "3rdparty/rapidjson/fwd.h" #include "base/crypto/Algorithm.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/Env.cpp b/src/base/io/Env.cpp similarity index 96% rename from src/base/kernel/Env.cpp rename to src/base/io/Env.cpp index 9b018e6e..ae1c27b5 100644 --- a/src/base/kernel/Env.cpp +++ b/src/base/io/Env.cpp @@ -23,7 +23,7 @@ */ -#include "base/kernel/Env.h" +#include "base/io/Env.h" #include "base/kernel/Process.h" #include "version.h" @@ -57,6 +57,8 @@ static std::map variables; static void createVariables() { variables.insert({ "XMRIG_VERSION", APP_VERSION }); + variables.insert({ "XMRIG_KIND", APP_KIND }); + variables.insert({ "XMRIG_HOSTNAME", Env::hostname() }); variables.insert({ "XMRIG_EXE", Process::exepath() }); variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation) }); variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation) }); diff --git a/src/base/kernel/Env.h b/src/base/io/Env.h similarity index 100% rename from src/base/kernel/Env.h rename to src/base/io/Env.h diff --git a/src/base/kernel/Signals.cpp b/src/base/io/Signals.cpp similarity index 98% rename from src/base/kernel/Signals.cpp rename to src/base/io/Signals.cpp index 87825b83..00ec8c17 100644 --- a/src/base/kernel/Signals.cpp +++ b/src/base/io/Signals.cpp @@ -26,8 +26,8 @@ #include +#include "base/io/Signals.h" #include "base/kernel/interfaces/ISignalListener.h" -#include "base/kernel/Signals.h" #include "base/tools/Handle.h" diff --git a/src/base/kernel/Signals.h b/src/base/io/Signals.h similarity index 100% rename from src/base/kernel/Signals.h rename to src/base/io/Signals.h diff --git a/src/base/io/json/Json.cpp b/src/base/io/json/Json.cpp index b239777b..a9be7dc3 100644 --- a/src/base/io/json/Json.cpp +++ b/src/base/io/json/Json.cpp @@ -24,7 +24,7 @@ #include "base/io/json/Json.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" #include diff --git a/src/base/io/json/Json.h b/src/base/io/json/Json.h index 10e6e696..683eb308 100644 --- a/src/base/io/json/Json.h +++ b/src/base/io/json/Json.h @@ -26,8 +26,10 @@ #define XMRIG_JSON_H +#include "3rdparty/rapidjson/fwd.h" #include "base/kernel/interfaces/IJsonReader.h" -#include "rapidjson/fwd.h" + + #include #include #include diff --git a/src/base/io/json/JsonChain.cpp b/src/base/io/json/JsonChain.cpp index 48f04be7..843c991c 100644 --- a/src/base/io/json/JsonChain.cpp +++ b/src/base/io/json/JsonChain.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -23,10 +23,10 @@ */ -#include "base/io/json/Json.h" #include "base/io/json/JsonChain.h" +#include "3rdparty/rapidjson/error/en.h" +#include "base/io/json/Json.h" #include "base/io/log/Log.h" -#include "rapidjson/error/en.h" namespace xmrig { diff --git a/src/base/io/json/JsonChain.h b/src/base/io/json/JsonChain.h index 275f789e..90f30742 100644 --- a/src/base/io/json/JsonChain.h +++ b/src/base/io/json/JsonChain.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 +29,9 @@ #include +#include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IJsonReader.h" #include "base/tools/String.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/base/io/json/JsonRequest.cpp b/src/base/io/json/JsonRequest.cpp index d66040a7..cacbdc80 100644 --- a/src/base/io/json/JsonRequest.cpp +++ b/src/base/io/json/JsonRequest.cpp @@ -24,7 +24,7 @@ #include "base/io/json/JsonRequest.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" namespace xmrig { diff --git a/src/base/io/json/JsonRequest.h b/src/base/io/json/JsonRequest.h index b2e0b156..88dbbad6 100644 --- a/src/base/io/json/JsonRequest.h +++ b/src/base/io/json/JsonRequest.h @@ -26,7 +26,7 @@ #define XMRIG_JSONREQUEST_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/io/json/Json_unix.cpp b/src/base/io/json/Json_unix.cpp index f31e1bd0..328dda34 100644 --- a/src/base/io/json/Json_unix.cpp +++ b/src/base/io/json/Json_unix.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,10 +27,10 @@ #include "base/io/json/Json.h" -#include "rapidjson/document.h" -#include "rapidjson/istreamwrapper.h" -#include "rapidjson/ostreamwrapper.h" -#include "rapidjson/prettywriter.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/istreamwrapper.h" +#include "3rdparty/rapidjson/ostreamwrapper.h" +#include "3rdparty/rapidjson/prettywriter.h" bool xmrig::Json::get(const char *fileName, rapidjson::Document &doc) diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index a9c4065a..87c79c24 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,10 +37,10 @@ #include "base/io/json/Json.h" -#include "rapidjson/document.h" -#include "rapidjson/istreamwrapper.h" -#include "rapidjson/ostreamwrapper.h" -#include "rapidjson/prettywriter.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/istreamwrapper.h" +#include "3rdparty/rapidjson/ostreamwrapper.h" +#include "3rdparty/rapidjson/prettywriter.h" namespace xmrig { diff --git a/src/base/io/log/FileLogWriter.cpp b/src/base/io/log/FileLogWriter.cpp index 8ae31273..921d9337 100644 --- a/src/base/io/log/FileLogWriter.cpp +++ b/src/base/io/log/FileLogWriter.cpp @@ -18,7 +18,7 @@ #include "base/io/log/FileLogWriter.h" -#include "base/kernel/Env.h" +#include "base/io/Env.h" #include diff --git a/src/base/io/log/Log.h b/src/base/io/log/Log.h index 45183d1c..b4675757 100644 --- a/src/base/io/log/Log.h +++ b/src/base/io/log/Log.h @@ -141,7 +141,9 @@ private: #define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__) #define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__) #define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__) -#define LOG_VERBOSE(x, ...) if (xmrig::Log::isVerbose()) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); } +#define LOG_VERBOSE(x, ...) if (xmrig::Log::verbose() > 0) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); } +#define LOG_V(x, ...) if (xmrig::Log::verbose() > 0) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); } +#define LOG_VV(x, ...) if (xmrig::Log::verbose() > 1) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); } #ifdef APP_DEBUG # define LOG_DEBUG(x, ...) xmrig::Log::print(xmrig::Log::DEBUG, x, ##__VA_ARGS__) diff --git a/src/base/kernel/Base.h b/src/base/kernel/Base.h index 756b6caf..f113c0f7 100644 --- a/src/base/kernel/Base.h +++ b/src/base/kernel/Base.h @@ -26,11 +26,11 @@ #define XMRIG_BASE_H +#include "3rdparty/rapidjson/fwd.h" #include "base/api/interfaces/IApiListener.h" #include "base/kernel/interfaces/IConfigListener.h" #include "base/kernel/interfaces/IWatcherListener.h" #include "base/tools/Object.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index 341b4dfd..3fcf666b 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/Platform.h @@ -48,9 +48,7 @@ public: } static bool setThreadAffinity(uint64_t cpu_id); - 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); diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index aab00675..5a5520eb 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -34,10 +34,6 @@ #include "base/kernel/Platform.h" #include "version.h" -#ifdef XMRIG_NVIDIA_PROJECT -# include "nvidia/cryptonight.h" -#endif - char *xmrig::Platform::createUserAgent() { @@ -46,11 +42,6 @@ char *xmrig::Platform::createUserAgent() 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(); - 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__) @@ -75,17 +66,6 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) #endif -uint32_t xmrig::Platform::setTimerResolution(uint32_t resolution) -{ - return resolution; -} - - -void xmrig::Platform::restoreTimerResolution() -{ -} - - void xmrig::Platform::setProcessPriority(int) { } diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index ba55ed77..6d957636 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -43,10 +43,6 @@ #include "base/kernel/Platform.h" #include "version.h" -#ifdef XMRIG_NVIDIA_PROJECT -# include "nvidia/cryptonight.h" -#endif - #ifdef __FreeBSD__ typedef cpuset_t cpu_set_t; @@ -70,11 +66,6 @@ char *xmrig::Platform::createUserAgent() length += snprintf(buf + length, max - length, "i686) libuv/%s", uv_version_string()); # endif -# ifdef XMRIG_NVIDIA_PROJECT - const int cudaVersion = cuda_get_runtime_version(); - 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__) @@ -104,17 +95,6 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) #endif -uint32_t xmrig::Platform::setTimerResolution(uint32_t resolution) -{ - return resolution; -} - - -void xmrig::Platform::restoreTimerResolution() -{ -} - - void xmrig::Platform::setProcessPriority(int) { } diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index ce7e60e2..018dba31 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -29,23 +29,12 @@ #include "base/kernel/Platform.h" -#include "base/io/log/Log.h" #include "version.h" -#ifdef XMRIG_NVIDIA_PROJECT -# include "nvidia/cryptonight.h" -#endif - - -#ifdef XMRIG_AMD_PROJECT -static uint32_t timerResolution = 0; -#endif - - static inline OSVERSIONINFOEX winOsVersion() { - typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); + using RtlGetVersionFunction = NTSTATUS (*)(LPOSVERSIONINFO); OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0}; HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); @@ -75,11 +64,6 @@ char *xmrig::Platform::createUserAgent() length += snprintf(buf + length, max - length, ") libuv/%s", uv_version_string()); # endif -# ifdef XMRIG_NVIDIA_PROJECT - const int cudaVersion = cuda_get_runtime_version(); - length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100); -# endif - # ifdef __GNUC__ length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); # elif _MSC_VER @@ -93,10 +77,6 @@ char *xmrig::Platform::createUserAgent() #ifndef XMRIG_FEATURE_HWLOC bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) { - if (cpu_id >= 64) { - LOG_ERR("Unable to set affinity. Windows supports only affinity up to 63."); - } - const bool result = (SetThreadAffinityMask(GetCurrentThread(), 1ULL << cpu_id) != 0); Sleep(1); return result; @@ -104,34 +84,6 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) #endif -uint32_t xmrig::Platform::setTimerResolution(uint32_t resolution) -{ -# ifdef XMRIG_AMD_PROJECT - TIMECAPS tc; - - if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) { - return 0; - } - - timerResolution = std::min(std::max(tc.wPeriodMin, resolution), tc.wPeriodMax); - - return timeBeginPeriod(timerResolution) == TIMERR_NOERROR ? timerResolution : 0; -# else - return resolution; -# endif -} - - -void xmrig::Platform::restoreTimerResolution() -{ -# ifdef XMRIG_AMD_PROJECT - if (timerResolution) { - timeEndPeriod(timerResolution); - } -# endif -} - - void xmrig::Platform::setProcessPriority(int priority) { if (priority == -1) { diff --git a/src/base/kernel/Process.cpp b/src/base/kernel/Process.cpp index 34f5d02b..36dcae78 100644 --- a/src/base/kernel/Process.cpp +++ b/src/base/kernel/Process.cpp @@ -115,7 +115,27 @@ xmrig::Process::Process(int argc, char **argv) : { srand(static_cast(Chrono::currentMSecsSinceEpoch() ^ reinterpret_cast(this))); - setDataDir(m_arguments.value("--data-dir")); + setDataDir(m_arguments.value("--data-dir", "-d")); +} + + +int xmrig::Process::pid() +{ +# if UV_VERSION_HEX >= 0x011200 + return uv_os_getpid(); +# else + return 0; +# endif +} + + +int xmrig::Process::ppid() +{ +# if UV_VERSION_HEX >= 0x011000 + return uv_os_getppid(); +# else + return 0; +# endif } diff --git a/src/base/kernel/Process.h b/src/base/kernel/Process.h index 29f247f2..a97a3dcc 100644 --- a/src/base/kernel/Process.h +++ b/src/base/kernel/Process.h @@ -51,6 +51,8 @@ public: Process(int argc, char **argv); + static int pid(); + static int ppid(); static String exepath(); static String location(Location location, const char *fileName = nullptr); diff --git a/src/base/kernel/config/BaseConfig.cpp b/src/base/kernel/config/BaseConfig.cpp index 12f5db74..1fe2d1ed 100644 --- a/src/base/kernel/config/BaseConfig.cpp +++ b/src/base/kernel/config/BaseConfig.cpp @@ -24,10 +24,10 @@ #include "base/kernel/config/BaseConfig.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IJsonReader.h" -#include "rapidjson/document.h" #include "version.h" diff --git a/src/base/kernel/config/BaseTransform.h b/src/base/kernel/config/BaseTransform.h index 9550328a..d6c08821 100644 --- a/src/base/kernel/config/BaseTransform.h +++ b/src/base/kernel/config/BaseTransform.h @@ -26,9 +26,9 @@ #define XMRIG_BASETRANSFORM_H +#include "3rdparty/rapidjson/document.h" #include "base/crypto/Coin.h" #include "base/kernel/interfaces/IConfigTransform.h" -#include "rapidjson/document.h" struct option; diff --git a/src/base/kernel/interfaces/IClient.h b/src/base/kernel/interfaces/IClient.h index 9349aa6a..8a8776ba 100644 --- a/src/base/kernel/interfaces/IClient.h +++ b/src/base/kernel/interfaces/IClient.h @@ -26,7 +26,7 @@ #define XMRIG_ICLIENT_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" #include diff --git a/src/base/kernel/interfaces/IClientListener.h b/src/base/kernel/interfaces/IClientListener.h index 45b0bcfd..4f2be302 100644 --- a/src/base/kernel/interfaces/IClientListener.h +++ b/src/base/kernel/interfaces/IClientListener.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,7 +29,7 @@ #include -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index 32f4b29b..7e5c255d 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -26,7 +26,7 @@ #define XMRIG_ICONFIG_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/interfaces/IConfigTransform.h b/src/base/kernel/interfaces/IConfigTransform.h index 571d3e5a..c8ada0b8 100644 --- a/src/base/kernel/interfaces/IConfigTransform.h +++ b/src/base/kernel/interfaces/IConfigTransform.h @@ -26,7 +26,7 @@ #define XMRIG_ICONFIGTRANSFORM_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/interfaces/IDnsListener.h b/src/base/kernel/interfaces/IDnsListener.h index 3683ea51..4cbb3f7e 100644 --- a/src/base/kernel/interfaces/IDnsListener.h +++ b/src/base/kernel/interfaces/IDnsListener.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/base/kernel/interfaces/IJsonReader.h b/src/base/kernel/interfaces/IJsonReader.h index c0fe09cb..b545514d 100644 --- a/src/base/kernel/interfaces/IJsonReader.h +++ b/src/base/kernel/interfaces/IJsonReader.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,7 +26,7 @@ #define XMRIG_IJSONREADER_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/kernel/interfaces/ILineListener.h b/src/base/kernel/interfaces/ILineListener.h index 2759dcec..a7d34901 100644 --- a/src/base/kernel/interfaces/ILineListener.h +++ b/src/base/kernel/interfaces/ILineListener.h @@ -26,6 +26,9 @@ #define XMRIG_ILINELISTENER_H +#include "base/tools/Object.h" + + #include @@ -35,7 +38,10 @@ namespace xmrig { class ILineListener { public: - virtual ~ILineListener() = default; + XMRIG_DISABLE_COPY_MOVE(ILineListener) + + ILineListener() = default; + virtual ~ILineListener() = default; virtual void onLine(char *line, size_t size) = 0; }; diff --git a/src/base/kernel/interfaces/IStrategyListener.h b/src/base/kernel/interfaces/IStrategyListener.h index 8b88b506..4d99ce7f 100644 --- a/src/base/kernel/interfaces/IStrategyListener.h +++ b/src/base/kernel/interfaces/IStrategyListener.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,7 +26,7 @@ #define XMRIG_ISTRATEGYLISTENER_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/net/dns/Dns.cpp b/src/base/net/dns/Dns.cpp index 40d2a6e3..6246421c 100644 --- a/src/base/net/dns/Dns.cpp +++ b/src/base/net/dns/Dns.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -23,9 +23,8 @@ */ -#include "base/kernel/interfaces/IDnsListener.h" #include "base/net/dns/Dns.h" -#include "base/tools/Handle.h" +#include "base/kernel/interfaces/IDnsListener.h" namespace xmrig { @@ -35,10 +34,7 @@ namespace xmrig { xmrig::Dns::Dns(IDnsListener *listener) : - m_hints(), - m_listener(listener), - m_status(0), - m_resolver(nullptr) + m_listener(listener) { m_key = m_storage.add(this); @@ -134,11 +130,11 @@ void xmrig::Dns::onResolved(int status, addrinfo *res) addrinfo *ptr = res; while (ptr != nullptr) { if (ptr->ai_family == AF_INET) { - m_ipv4.push_back(ptr); + m_ipv4.emplace_back(ptr); } if (ptr->ai_family == AF_INET6) { - m_ipv6.push_back(ptr); + m_ipv6.emplace_back(ptr); } ptr = ptr->ai_next; diff --git a/src/base/net/dns/Dns.h b/src/base/net/dns/Dns.h index 11f5bf80..068ab80f 100644 --- a/src/base/net/dns/Dns.h +++ b/src/base/net/dns/Dns.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -32,6 +32,7 @@ #include "base/net/dns/DnsRecord.h" #include "base/net/tools/Storage.h" +#include "base/tools/Object.h" #include "base/tools/String.h" @@ -44,6 +45,8 @@ class IDnsListener; class Dns { public: + XMRIG_DISABLE_COPY_MOVE_DEFAULT(Dns) + Dns(IDnsListener *listener); ~Dns(); @@ -62,14 +65,14 @@ private: static void onResolved(uv_getaddrinfo_t *req, int status, addrinfo *res); - addrinfo m_hints; + addrinfo m_hints{}; IDnsListener *m_listener; - int m_status; + int m_status = 0; std::vector m_ipv4; std::vector m_ipv6; String m_host; uintptr_t m_key; - uv_getaddrinfo_t *m_resolver; + uv_getaddrinfo_t *m_resolver = nullptr; static Storage m_storage; }; diff --git a/src/base/net/http/Fetch.cpp b/src/base/net/http/Fetch.cpp index a0eb2b55..4d18b71d 100644 --- a/src/base/net/http/Fetch.cpp +++ b/src/base/net/http/Fetch.cpp @@ -18,12 +18,11 @@ #include "base/net/http/Fetch.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/stringbuffer.h" +#include "3rdparty/rapidjson/writer.h" #include "base/io/log/Log.h" #include "base/net/http/HttpClient.h" -#include "base/net/stratum/Pool.h" -#include "rapidjson/document.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/writer.h" #ifdef XMRIG_FEATURE_TLS @@ -45,7 +44,7 @@ xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16 } -xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Document &doc, bool tls, bool quiet) : +xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls, bool quiet) : quiet(quiet), tls(tls), method(method), @@ -55,42 +54,10 @@ xmrig::FetchRequest::FetchRequest(http_method method, const String &host, uint16 { assert(port > 0); - setBody(doc); + setBody(value); } -xmrig::FetchRequest::FetchRequest(int method, const Pool &pool, const String &path, bool quiet, const char *data, size_t size, const char *contentType) : - quiet(quiet), - tls(pool.isTLS()), - method(static_cast(method)), - fingerprint(pool.fingerprint()), - host(pool.host()), - path(path), - port(pool.port()) -{ - assert(pool.isValid()); - - setBody(data, size, contentType); -} - - - -xmrig::FetchRequest::FetchRequest(int method, const Pool &pool, const String &path, const rapidjson::Document &doc, bool quiet) : - quiet(quiet), - tls(pool.isTLS()), - method(static_cast(method)), - fingerprint(pool.fingerprint()), - host(pool.host()), - path(path), - port(pool.port()) -{ - assert(pool.isValid()); - - setBody(doc); -} - - - void xmrig::FetchRequest::setBody(const char *data, size_t size, const char *contentType) { if (!data) { @@ -110,7 +77,7 @@ void xmrig::FetchRequest::setBody(const char *data, size_t size, const char *con } -void xmrig::FetchRequest::setBody(const rapidjson::Document &doc) +void xmrig::FetchRequest::setBody(const rapidjson::Value &value) { assert(method != HTTP_GET && method != HTTP_HEAD); @@ -122,7 +89,7 @@ void xmrig::FetchRequest::setBody(const rapidjson::Document &doc) StringBuffer buffer(nullptr, 512); Writer writer(buffer); - doc.Accept(writer); + value.Accept(writer); setBody(buffer.GetString(), buffer.GetSize(), HttpData::kApplicationJson.c_str()); } diff --git a/src/base/net/http/Fetch.h b/src/base/net/http/Fetch.h index db1e899b..b6fbf487 100644 --- a/src/base/net/http/Fetch.h +++ b/src/base/net/http/Fetch.h @@ -22,8 +22,8 @@ #include "3rdparty/http-parser/http_parser.h" +#include "3rdparty/rapidjson/fwd.h" #include "base/tools/String.h" -#include "rapidjson/fwd.h" #include @@ -35,7 +35,6 @@ namespace xmrig { class IHttpListener; -class Pool; class FetchRequest @@ -43,12 +42,10 @@ class FetchRequest public: FetchRequest() = default; FetchRequest(http_method method, const String &host, uint16_t port, const String &path, bool tls = false, bool quiet = false, const char *data = nullptr, size_t size = 0, const char *contentType = nullptr); - FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Document &doc, bool tls = false, bool quiet = false); - FetchRequest(int method, const Pool &pool, const String &path, bool quiet = false, const char *data = nullptr, size_t size = 0, const char *contentType = nullptr); - FetchRequest(int method, const Pool &pool, const String &path, const rapidjson::Document &doc, bool quiet = false); + FetchRequest(http_method method, const String &host, uint16_t port, const String &path, const rapidjson::Value &value, bool tls = false, bool quiet = false); void setBody(const char *data, size_t size, const char *contentType = nullptr); - void setBody(const rapidjson::Document &doc); + void setBody(const rapidjson::Value &value); inline bool hasBody() const { return method != HTTP_GET && method != HTTP_HEAD && !body.empty(); } diff --git a/src/base/net/http/HttpApiResponse.cpp b/src/base/net/http/HttpApiResponse.cpp index 6bf23c45..fed3df53 100644 --- a/src/base/net/http/HttpApiResponse.cpp +++ b/src/base/net/http/HttpApiResponse.cpp @@ -26,9 +26,9 @@ #include "base/net/http/HttpApiResponse.h" #include "3rdparty/http-parser/http_parser.h" +#include "3rdparty/rapidjson/prettywriter.h" +#include "3rdparty/rapidjson/stringbuffer.h" #include "base/net/http/HttpData.h" -#include "rapidjson/prettywriter.h" -#include "rapidjson/stringbuffer.h" namespace xmrig { diff --git a/src/base/net/http/HttpApiResponse.h b/src/base/net/http/HttpApiResponse.h index a5070735..8a782510 100644 --- a/src/base/net/http/HttpApiResponse.h +++ b/src/base/net/http/HttpApiResponse.h @@ -28,8 +28,8 @@ #define XMRIG_HTTPAPIRESPONSE_H +#include "3rdparty/rapidjson/document.h" #include "base/net/http/HttpResponse.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/base/net/http/HttpData.cpp b/src/base/net/http/HttpData.cpp index 5aa575a8..6e75e2ac 100644 --- a/src/base/net/http/HttpData.cpp +++ b/src/base/net/http/HttpData.cpp @@ -26,6 +26,19 @@ namespace xmrig { const std::string HttpData::kApplicationJson = "application/json"; const std::string HttpData::kContentType = "Content-Type"; const std::string HttpData::kContentTypeL = "content-type"; +const std::string HttpData::kTextPlain = "text/plain"; } // namespace xmrig + + +bool xmrig::HttpData::isJSON() const +{ + if (!headers.count(kContentTypeL)) { + return false; + } + + auto &type = headers.at(kContentTypeL); + + return type == kApplicationJson || type == kTextPlain; +} diff --git a/src/base/net/http/HttpData.h b/src/base/net/http/HttpData.h index 82a8ee8f..2e8b78f8 100644 --- a/src/base/net/http/HttpData.h +++ b/src/base/net/http/HttpData.h @@ -46,12 +46,13 @@ public: static const std::string kApplicationJson; static const std::string kContentType; static const std::string kContentTypeL; + static const std::string kTextPlain; inline HttpData(uint64_t id) : m_id(id) {} virtual ~HttpData() = default; - inline uint64_t id() const { return m_id; } + inline uint64_t id() const { return m_id; } virtual bool isRequest() const = 0; virtual const char *host() const = 0; @@ -61,6 +62,8 @@ public: virtual uint16_t port() const = 0; virtual void write(std::string &&data, bool close) = 0; + bool isJSON() const; + int method = 0; int status = 0; int userType = 0; diff --git a/src/base/net/http/HttpListener.cpp b/src/base/net/http/HttpListener.cpp index e58d5e55..077184fc 100644 --- a/src/base/net/http/HttpListener.cpp +++ b/src/base/net/http/HttpListener.cpp @@ -27,11 +27,11 @@ void xmrig::HttpListener::onHttpData(const HttpData &data) { # ifdef APP_DEBUG if (!data.isRequest()) { - LOG_DEBUG(CYAN("http%s://%s:%u ") MAGENTA_BOLD("\"%s %s\" ") CSI "1;%dm%d" CLEAR BLACK_BOLD(" received: ") CYAN_BOLD("%zu") BLACK_BOLD(" bytes"), - data.tlsVersion() ? "s" : "", data.host(), data.port(), http_method_str(static_cast(data.method)), data.url.data(), - data.status >= 400 ? 31 : 32, data.status, data.body.size()); + LOG_DEBUG("%s " CYAN_BOLD("http%s://%s:%u ") MAGENTA_BOLD("\"%s %s\" ") CSI "1;%dm%d" CLEAR BLACK_BOLD(" received: ") CYAN_BOLD("%zu") BLACK_BOLD(" bytes"), + m_tag, data.tlsVersion() ? "s" : "", data.host(), data.port(), http_method_str(static_cast(data.method)), data.url.data(), + (data.status >= 400 || data.status < 0) ? 31 : 32, data.status, data.body.size()); - if (data.body.size() < (Log::kMaxBufferSize - 1024) && data.headers.count(HttpData::kContentTypeL) && data.headers.at(HttpData::kContentTypeL) == HttpData::kApplicationJson) { + if (data.body.size() < (Log::kMaxBufferSize - 1024) && data.isJSON()) { Log::print(BLUE_BG_BOLD("%s:") BLACK_BOLD_S " %.*s", data.headers.at(HttpData::kContentTypeL).c_str(), static_cast(data.body.size()), data.body.c_str()); } } diff --git a/src/base/net/http/HttpListener.h b/src/base/net/http/HttpListener.h index 36975db4..ac302dab 100644 --- a/src/base/net/http/HttpListener.h +++ b/src/base/net/http/HttpListener.h @@ -29,12 +29,13 @@ namespace xmrig { class HttpListener : public IHttpListener { public: - inline HttpListener(IHttpListener *listener) : m_listener(listener) {} + inline HttpListener(IHttpListener *listener, const char *tag = nullptr) : m_tag(tag), m_listener(listener) {} protected: void onHttpData(const HttpData &data) override; private: + const char *m_tag; IHttpListener *m_listener; }; diff --git a/src/base/net/stratum/BaseClient.cpp b/src/base/net/stratum/BaseClient.cpp index 677b0e37..6072a666 100644 --- a/src/base/net/stratum/BaseClient.cpp +++ b/src/base/net/stratum/BaseClient.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,10 +24,10 @@ #include "base/net/stratum/BaseClient.h" -#include "base/kernel/Env.h" +#include "3rdparty/rapidjson/document.h" +#include "base/io/Env.h" #include "base/kernel/interfaces/IClientListener.h" #include "base/net/stratum/SubmitResult.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 95de98c7..81574016 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -39,6 +39,10 @@ #include "base/net/stratum/Client.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/error/en.h" +#include "3rdparty/rapidjson/stringbuffer.h" +#include "3rdparty/rapidjson/writer.h" #include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" @@ -49,10 +53,6 @@ #include "base/tools/Buffer.h" #include "base/tools/Chrono.h" #include "net/JobResult.h" -#include "rapidjson/document.h" -#include "rapidjson/error/en.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/writer.h" #ifdef _MSC_VER diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index bdf6d5ca..59e2a6ff 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -26,6 +26,8 @@ #include "base/net/stratum/DaemonClient.h" #include "3rdparty/http-parser/http_parser.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/error/en.h" #include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" @@ -36,8 +38,6 @@ #include "base/tools/Buffer.h" #include "base/tools/Timer.h" #include "net/JobResult.h" -#include "rapidjson/document.h" -#include "rapidjson/error/en.h" #include @@ -328,7 +328,7 @@ int64_t xmrig::DaemonClient::getBlockTemplate() int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc) { - FetchRequest req(HTTP_POST, m_pool, kJsonRPC, doc, isQuiet()); + FetchRequest req(HTTP_POST, m_pool.host(), m_pool.port(), kJsonRPC, doc, m_pool.isTLS(), isQuiet()); fetch(std::move(req), m_httpListener); return m_sequence++; @@ -355,7 +355,7 @@ void xmrig::DaemonClient::retry() void xmrig::DaemonClient::send(const char *path) { - FetchRequest req(HTTP_GET, m_pool, path, isQuiet()); + FetchRequest req(HTTP_GET, m_pool.host(), m_pool.port(), path, m_pool.isTLS(), isQuiet()); fetch(std::move(req), m_httpListener); } diff --git a/src/base/net/stratum/NetworkState.cpp b/src/base/net/stratum/NetworkState.cpp index 29d911e1..16f76336 100644 --- a/src/base/net/stratum/NetworkState.cpp +++ b/src/base/net/stratum/NetworkState.cpp @@ -24,13 +24,13 @@ #include "base/net/stratum/NetworkState.h" +#include "3rdparty/rapidjson/document.h" #include "base/kernel/interfaces/IClient.h" #include "base/kernel/interfaces/IStrategy.h" #include "base/net/stratum/Job.h" #include "base/net/stratum/Pool.h" #include "base/net/stratum/SubmitResult.h" #include "base/tools/Chrono.h" -#include "rapidjson/document.h" #include diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index e112feca..afd7433f 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -32,11 +32,11 @@ #include "base/net/stratum/Pool.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" #include "base/io/log/Log.h" #include "base/kernel/Platform.h" #include "base/net/stratum/Client.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_HTTP diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index 02855200..95703eca 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -31,9 +31,9 @@ #include +#include "3rdparty/rapidjson/fwd.h" #include "base/crypto/Coin.h" #include "base/net/stratum/ProxyUrl.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/net/stratum/Pools.cpp b/src/base/net/stratum/Pools.cpp index a65e26b1..90655547 100644 --- a/src/base/net/stratum/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -24,12 +24,12 @@ #include "base/net/stratum/Pools.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IJsonReader.h" #include "base/net/stratum/strategies/FailoverStrategy.h" #include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "donate.h" -#include "rapidjson/document.h" namespace xmrig { diff --git a/src/base/net/stratum/ProxyUrl.cpp b/src/base/net/stratum/ProxyUrl.cpp index 5b0ff281..ad4542bc 100644 --- a/src/base/net/stratum/ProxyUrl.cpp +++ b/src/base/net/stratum/ProxyUrl.cpp @@ -18,7 +18,7 @@ #include "base/net/stratum/ProxyUrl.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" namespace xmrig { diff --git a/src/base/net/stratum/SelfSelectClient.cpp b/src/base/net/stratum/SelfSelectClient.cpp index 6fdcf14d..8ad48b65 100644 --- a/src/base/net/stratum/SelfSelectClient.cpp +++ b/src/base/net/stratum/SelfSelectClient.cpp @@ -26,14 +26,14 @@ #include "base/net/stratum/SelfSelectClient.h" #include "3rdparty/http-parser/http_parser.h" +#include "3rdparty/rapidjson/document.h" +#include "3rdparty/rapidjson/error/en.h" #include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" #include "base/net/http/Fetch.h" #include "base/net/http/HttpData.h" #include "base/net/stratum/Client.h" -#include "rapidjson/document.h" -#include "rapidjson/error/en.h" namespace xmrig { diff --git a/src/base/net/tls/TlsConfig.cpp b/src/base/net/tls/TlsConfig.cpp index 49b1970d..2e3dc903 100644 --- a/src/base/net/tls/TlsConfig.cpp +++ b/src/base/net/tls/TlsConfig.cpp @@ -25,10 +25,10 @@ #include "base/net/tls/TlsConfig.h" +#include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" #include "base/io/log/Log.h" #include "base/net/tls/TlsGen.h" -#include "rapidjson/document.h" namespace xmrig { @@ -86,7 +86,7 @@ xmrig::TlsConfig::TlsConfig(const rapidjson::Value &value) generate(); } } -# ifdef XMRIG_PROXY_PROJECT +# ifdef XMRIG_FORCE_TLS else if (value.IsNull()) { generate(); } diff --git a/src/base/net/tls/TlsConfig.h b/src/base/net/tls/TlsConfig.h index 4e0fe787..c5407f32 100644 --- a/src/base/net/tls/TlsConfig.h +++ b/src/base/net/tls/TlsConfig.h @@ -27,8 +27,8 @@ #define XMRIG_TLSCONFIG_H +#include "3rdparty/rapidjson/fwd.h" #include "base/tools/String.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/base/net/tls/TlsContext.cpp b/src/base/net/tls/TlsContext.cpp index d2ab71c5..03c79e65 100644 --- a/src/base/net/tls/TlsContext.cpp +++ b/src/base/net/tls/TlsContext.cpp @@ -25,8 +25,8 @@ #include "base/net/tls/TlsContext.h" +#include "base/io/Env.h" #include "base/io/log/Log.h" -#include "base/kernel/Env.h" #include "base/net/tls/TlsConfig.h" diff --git a/src/base/net/tools/Storage.h b/src/base/net/tools/Storage.h index 0af4db26..e23e8666 100644 --- a/src/base/net/tools/Storage.h +++ b/src/base/net/tools/Storage.h @@ -1,10 +1,4 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , * Copyright 2018-2020 SChernykh * Copyright 2016-2020 XMRig , * @@ -48,10 +42,10 @@ public: } - inline static void *ptr(uintptr_t id) { return reinterpret_cast(id); } + inline void *ptr(uintptr_t id) { return reinterpret_cast(id); } - inline TYPE *get(const void *id) const { return get(reinterpret_cast(id)); } + inline TYPE *get(const void *id) const { return get(reinterpret_cast(id)); } inline TYPE *get(uintptr_t id) const { assert(m_data.count(id) > 0); @@ -63,19 +57,16 @@ public: } - inline void remove(const void *id) { delete release(reinterpret_cast(id)); } - inline void remove(uintptr_t id) { delete release(id); } + inline void remove(const void *id) { delete release(reinterpret_cast(id)); } + inline void remove(uintptr_t id) { delete release(id); } - inline TYPE *release(const void *id) { release(reinterpret_cast(id)); } + inline TYPE *release(const void *id) { return release(reinterpret_cast(id)); } inline TYPE *release(uintptr_t id) { - TYPE *obj = get(id); + auto obj = get(id); if (obj != nullptr) { - auto it = m_data.find(id); - if (it != m_data.end()) { - m_data.erase(it); - } + m_data.erase(id); } return obj; @@ -84,7 +75,7 @@ public: private: std::map m_data; - uint64_t m_counter = 0; + uintptr_t m_counter = 0; }; diff --git a/src/base/tools/Arguments.cpp b/src/base/tools/Arguments.cpp index d0352939..eebe0e73 100644 --- a/src/base/tools/Arguments.cpp +++ b/src/base/tools/Arguments.cpp @@ -52,7 +52,7 @@ bool xmrig::Arguments::hasArg(const char *name) const } -const char *xmrig::Arguments::value(const char *key) const +const char *xmrig::Arguments::value(const char *key1, const char *key2) const { const size_t size = m_data.size(); if (size < 3) { @@ -60,7 +60,7 @@ const char *xmrig::Arguments::value(const char *key) const } for (size_t i = 1; i < size - 1; ++i) { - if (m_data[i] == key) { + if (m_data[i] == key1 || (key2 && m_data[i] == key2)) { return m_data[i + 1]; } } diff --git a/src/base/tools/Arguments.h b/src/base/tools/Arguments.h index 0016c519..e7a10536 100644 --- a/src/base/tools/Arguments.h +++ b/src/base/tools/Arguments.h @@ -41,7 +41,7 @@ public: Arguments(int argc, char **argv); bool hasArg(const char *name) const; - const char *value(const char *key) const; + const char *value(const char *key1, const char *key2 = nullptr) const; inline char **argv() const { return m_argv; } inline const std::vector &data() const { return m_data; } diff --git a/src/base/tools/String.cpp b/src/base/tools/String.cpp index b11d6774..f9322274 100644 --- a/src/base/tools/String.cpp +++ b/src/base/tools/String.cpp @@ -23,11 +23,11 @@ */ -#include - - #include "base/tools/String.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" + + +#include xmrig::String::String(const char *str) : diff --git a/src/base/tools/String.h b/src/base/tools/String.h index 0f365641..df649576 100644 --- a/src/base/tools/String.h +++ b/src/base/tools/String.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,13 +26,13 @@ #define XMRIG_STRING_H +#include "3rdparty/rapidjson/fwd.h" + + #include #include -#include "rapidjson/fwd.h" - - namespace xmrig { @@ -85,11 +85,11 @@ public: rapidjson::Value toJSON() const; rapidjson::Value toJSON(rapidjson::Document &doc) const; - std::vector split(char sep) const; + std::vector split(char sep) const; String &toLower(); String &toUpper(); - static String join(const std::vector &vec, char sep); + static String join(const std::vector &vec, char sep); private: void copy(const char *str); diff --git a/src/base/tools/Timer.cpp b/src/base/tools/Timer.cpp index d06df163..858d1219 100644 --- a/src/base/tools/Timer.cpp +++ b/src/base/tools/Timer.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -23,22 +17,20 @@ */ +#include "base/tools/Timer.h" #include "base/kernel/interfaces/ITimerListener.h" #include "base/tools/Handle.h" -#include "base/tools/Timer.h" xmrig::Timer::Timer(ITimerListener *listener) : - m_listener(listener), - m_timer(nullptr) + m_listener(listener) { init(); } xmrig::Timer::Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat) : - m_listener(listener), - m_timer(nullptr) + m_listener(listener) { init(); start(timeout, repeat); @@ -63,6 +55,15 @@ void xmrig::Timer::setRepeat(uint64_t repeat) } +void xmrig::Timer::singleShot(uint64_t timeout, int id) +{ + m_id = id; + + stop(); + start(timeout, 0); +} + + void xmrig::Timer::start(uint64_t timeout, uint64_t repeat) { uv_timer_start(m_timer, onTimer, timeout, repeat); @@ -71,6 +72,7 @@ void xmrig::Timer::start(uint64_t timeout, uint64_t repeat) void xmrig::Timer::stop() { + setRepeat(0); uv_timer_stop(m_timer); } @@ -85,7 +87,7 @@ void xmrig::Timer::init() void xmrig::Timer::onTimer(uv_timer_t *handle) { - const Timer *timer = static_cast(handle->data); + const auto timer = static_cast(handle->data); timer->m_listener->onTimer(timer); } diff --git a/src/base/tools/Timer.h b/src/base/tools/Timer.h index e0e210f5..8fd040f8 100644 --- a/src/base/tools/Timer.h +++ b/src/base/tools/Timer.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,10 +20,13 @@ #define XMRIG_TIMER_H -#include +using uv_timer_t = struct uv_timer_s; -typedef struct uv_timer_s uv_timer_t; +#include "base/tools/Object.h" + + +#include namespace xmrig { @@ -41,12 +38,17 @@ class ITimerListener; class Timer { public: + XMRIG_DISABLE_COPY_MOVE_DEFAULT(Timer); + Timer(ITimerListener *listener); Timer(ITimerListener *listener, uint64_t timeout, uint64_t repeat); ~Timer(); + inline int id() const { return m_id; } + uint64_t repeat() const; void setRepeat(uint64_t repeat); + void singleShot(uint64_t timeout, int id = 0); void start(uint64_t timeout, uint64_t repeat); void stop(); @@ -55,8 +57,9 @@ private: static void onTimer(uv_timer_t *handle); + int m_id = 0; ITimerListener *m_listener; - uv_timer_t *m_timer; + uv_timer_t *m_timer = nullptr; }; diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 254428fb..78beeb8e 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -28,6 +28,8 @@ #include +#include "core/Miner.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Hashrate.h" #include "backend/cpu/Cpu.h" #include "backend/cpu/CpuBackend.h" @@ -38,11 +40,9 @@ #include "base/tools/Timer.h" #include "core/config/Config.h" #include "core/Controller.h" -#include "core/Miner.h" +#include "crypto/astrobwt/AstroBWT.h" #include "crypto/common/Nonce.h" #include "crypto/rx/Rx.h" -#include "crypto/astrobwt/AstroBWT.h" -#include "rapidjson/document.h" #include "version.h" diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index fe3c8c33..9fc6a830 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -28,14 +28,12 @@ #include +#include "core/config/Config.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cpu/Cpu.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IJsonReader.h" -#include "core/config/Config.h" #include "crypto/common/Assembly.h" -#include "rapidjson/document.h" -#include "rapidjson/filewritestream.h" -#include "rapidjson/prettywriter.h" #ifdef XMRIG_ALGO_RANDOMX diff --git a/src/core/config/Config.h b/src/core/config/Config.h index 997fa505..501b8c59 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -29,10 +29,10 @@ #include +#include "3rdparty/rapidjson/fwd.h" #include "backend/cpu/CpuConfig.h" #include "base/kernel/config/BaseConfig.h" #include "base/tools/Object.h" -#include "rapidjson/fwd.h" namespace xmrig { diff --git a/src/crypto/common/Assembly.cpp b/src/crypto/common/Assembly.cpp index 44bf0a94..5b7f8959 100644 --- a/src/crypto/common/Assembly.cpp +++ b/src/crypto/common/Assembly.cpp @@ -6,8 +6,8 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 SChernykh - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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,7 +34,7 @@ #include "crypto/common/Assembly.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" namespace xmrig { diff --git a/src/crypto/common/Assembly.h b/src/crypto/common/Assembly.h index 5ea29e11..803ea716 100644 --- a/src/crypto/common/Assembly.h +++ b/src/crypto/common/Assembly.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,7 +26,7 @@ #define XMRIG_ASSEMBLY_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" namespace xmrig { diff --git a/src/crypto/rx/RxConfig.cpp b/src/crypto/rx/RxConfig.cpp index 01d0616e..82336708 100644 --- a/src/crypto/rx/RxConfig.cpp +++ b/src/crypto/rx/RxConfig.cpp @@ -24,9 +24,9 @@ #include "crypto/rx/RxConfig.h" +#include "3rdparty/rapidjson/document.h" #include "backend/cpu/Cpu.h" #include "base/io/json/Json.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_HWLOC diff --git a/src/crypto/rx/RxConfig.h b/src/crypto/rx/RxConfig.h index e42b3a71..af2ac9df 100644 --- a/src/crypto/rx/RxConfig.h +++ b/src/crypto/rx/RxConfig.h @@ -26,7 +26,7 @@ #define XMRIG_RXCONFIG_H -#include "rapidjson/fwd.h" +#include "3rdparty/rapidjson/fwd.h" #ifdef XMRIG_FEATURE_MSR diff --git a/src/crypto/rx/msr/MsrItem.cpp b/src/crypto/rx/msr/MsrItem.cpp index 23cf5dc0..4c8e7f2a 100644 --- a/src/crypto/rx/msr/MsrItem.cpp +++ b/src/crypto/rx/msr/MsrItem.cpp @@ -7,8 +7,8 @@ * Copyright 2017-2019 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2018-2019 tevador - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -26,7 +26,7 @@ #include "crypto/rx/msr/MsrItem.h" -#include "rapidjson/document.h" +#include "3rdparty/rapidjson/document.h" #include diff --git a/src/crypto/rx/msr/MsrItem.h b/src/crypto/rx/msr/MsrItem.h index 5b84f432..b14fda3b 100644 --- a/src/crypto/rx/msr/MsrItem.h +++ b/src/crypto/rx/msr/MsrItem.h @@ -7,8 +7,8 @@ * Copyright 2017-2019 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2018-2019 tevador - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/donate.h b/src/donate.h index 46f26b73..a316389e 100644 --- a/src/donate.h +++ b/src/donate.h @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 +22,8 @@ * along with this program. If not, see . */ -#ifndef __DONATE_H__ -#define __DONATE_H__ +#ifndef XMRIG_DONATE_H +#define XMRIG_DONATE_H /* @@ -47,4 +48,4 @@ constexpr const int kDefaultDonateLevel = 5; constexpr const int kMinimumDonateLevel = 1; -#endif /* __DONATE_H__ */ +#endif /* XMRIG_DONATE_H */ diff --git a/src/net/Network.cpp b/src/net/Network.cpp index b2b32e01..976ea8c4 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -28,6 +28,7 @@ #endif #include "net/Network.h" +#include "3rdparty/rapidjson/document.h" #include "backend/common/Tags.h" #include "base/io/log/Log.h" #include "base/net/stratum/Client.h" @@ -41,7 +42,6 @@ #include "net/JobResult.h" #include "net/JobResults.h" #include "net/strategies/DonateStrategy.h" -#include "rapidjson/document.h" #ifdef XMRIG_FEATURE_API diff --git a/src/net/Network.h b/src/net/Network.h index 826c64d0..17490fca 100644 --- a/src/net/Network.h +++ b/src/net/Network.h @@ -27,13 +27,13 @@ #define XMRIG_NETWORK_H +#include "3rdparty/rapidjson/fwd.h" #include "base/api/interfaces/IApiListener.h" #include "base/kernel/interfaces/IBaseListener.h" #include "base/kernel/interfaces/IStrategyListener.h" #include "base/kernel/interfaces/ITimerListener.h" #include "base/tools/Object.h" #include "interfaces/IJobResultListener.h" -#include "rapidjson/fwd.h" #include diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index ace9cfa3..b1a9b6ca 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -29,6 +29,7 @@ #include "net/strategies/DonateStrategy.h" +#include "3rdparty/rapidjson/document.h" #include "base/crypto/keccak.h" #include "base/kernel/Platform.h" #include "base/net/stratum/Client.h" @@ -41,7 +42,6 @@ #include "core/Controller.h" #include "core/Miner.h" #include "net/Network.h" -#include "rapidjson/document.h" namespace xmrig {