diff --git a/CMakeLists.txt b/CMakeLists.txt index 94bf61b63..188f595ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,14 +23,24 @@ set(HEADERS src/App.h src/base/io/Json.h src/base/io/Watcher.h + src/base/kernel/Entry.h + src/base/kernel/interfaces/IClientListener.h src/base/kernel/interfaces/IConfigListener.h src/base/kernel/interfaces/ISignalListener.h + src/base/kernel/interfaces/IStrategy.h + src/base/kernel/interfaces/IStrategyListener.h src/base/kernel/interfaces/IWatcherListener.h - src/base/kernel/Entry.h src/base/kernel/Process.h src/base/kernel/Signals.h - src/base/net/Pool.h - src/base/net/Pools.h + src/base/net/stratum/Client.h + src/base/net/stratum/Id.h + src/base/net/stratum/Job.h + src/base/net/stratum/Pool.h + src/base/net/stratum/Pools.h + src/base/net/stratum/strategies/FailoverStrategy.h + src/base/net/stratum/strategies/SinglePoolStrategy.h + src/base/net/stratum/SubmitResult.h + src/base/net/tools/Storage.h src/base/tools/Arguments.h src/base/tools/Chrono.h src/base/tools/Handle.h @@ -42,32 +52,22 @@ set(HEADERS src/common/cpu/Cpu.h src/common/crypto/Algorithm.h src/common/crypto/keccak.h - src/common/interfaces/IClientListener.h src/common/interfaces/IConfig.h src/common/interfaces/IConfigCreator.h src/common/interfaces/IConsoleListener.h src/common/interfaces/IControllerListener.h src/common/interfaces/ICpuInfo.h src/common/interfaces/ILogBackend.h - src/common/interfaces/IStrategy.h - src/common/interfaces/IStrategyListener.h src/common/log/BasicLog.h src/common/log/ConsoleLog.h src/common/log/FileLog.h src/common/log/Log.h - src/common/net/Client.h - src/common/net/Id.h - src/common/net/Job.h - src/common/net/Storage.h - src/common/net/strategies/FailoverStrategy.h - src/common/net/strategies/SinglePoolStrategy.h - src/common/net/SubmitResult.h src/common/Platform.h src/common/utils/c_str.h src/common/utils/mm_malloc.h src/common/xmrig.h - src/core/ConfigLoader_platform.h src/core/ConfigLoader_default.h + src/core/ConfigLoader_platform.h src/core/Controller.h src/interfaces/IJobResultListener.h src/interfaces/IThread.h @@ -116,8 +116,13 @@ set(SOURCES src/base/kernel/Entry.cpp src/base/kernel/Process.cpp src/base/kernel/Signals.cpp - src/base/net/Pool.cpp - src/base/net/Pools.cpp + src/base/net/stratum/Client.cpp + src/base/net/stratum/Job.cpp + src/base/net/stratum/Pool.cpp + src/base/net/stratum/Pools.cpp + src/base/net/stratum/strategies/FailoverStrategy.cpp + src/base/net/stratum/strategies/SinglePoolStrategy.cpp + src/base/net/stratum/SubmitResult.cpp src/base/tools/Arguments.cpp src/base/tools/Handle.cpp src/base/tools/String.cpp @@ -131,11 +136,6 @@ set(SOURCES src/common/log/ConsoleLog.cpp src/common/log/FileLog.cpp src/common/log/Log.cpp - src/common/net/Client.cpp - src/common/net/Job.cpp - src/common/net/strategies/FailoverStrategy.cpp - src/common/net/strategies/SinglePoolStrategy.cpp - src/common/net/SubmitResult.cpp src/common/Platform.cpp src/core/Config.cpp src/core/Controller.cpp diff --git a/cmake/OpenSSL.cmake b/cmake/OpenSSL.cmake index 79731d6f7..5761f99f4 100644 --- a/cmake/OpenSSL.cmake +++ b/cmake/OpenSSL.cmake @@ -11,7 +11,7 @@ if (WITH_TLS) find_package(OpenSSL) if (OPENSSL_FOUND) - set(TLS_SOURCES src/common/net/Tls.h src/common/net/Tls.cpp) + set(TLS_SOURCES src/base/net/stratum/Tls.h src/base/net/stratum/Tls.cpp) include_directories(${OPENSSL_INCLUDE_DIR}) else() message(FATAL_ERROR "OpenSSL NOT found: use `-DWITH_TLS=OFF` to build without TLS support") diff --git a/src/Summary.cpp b/src/Summary.cpp index 60a9278f9..7a52d1b13 100644 --- a/src/Summary.cpp +++ b/src/Summary.cpp @@ -28,7 +28,7 @@ #include -#include "base/net/Pool.h" +#include "base/net/stratum/Pool.h" #include "common/cpu/Cpu.h" #include "common/log/Log.h" #include "core/Config.h" diff --git a/src/api/ApiRouter.cpp b/src/api/ApiRouter.cpp index bdedac4d3..ff99c0475 100644 --- a/src/api/ApiRouter.cpp +++ b/src/api/ApiRouter.cpp @@ -34,11 +34,11 @@ #include "api/ApiRouter.h" +#include "base/net/stratum/Job.h" #include "common/api/HttpReply.h" #include "common/api/HttpRequest.h" #include "common/cpu/Cpu.h" #include "common/crypto/keccak.h" -#include "common/net/Job.h" #include "common/Platform.h" #include "core/Config.h" #include "core/Controller.h" diff --git a/src/api/NetworkState.cpp b/src/api/NetworkState.cpp index 6ccc0d0fa..8a541eaa5 100644 --- a/src/api/NetworkState.cpp +++ b/src/api/NetworkState.cpp @@ -30,8 +30,8 @@ #include "api/NetworkState.h" +#include "base/net/stratum/SubmitResult.h" #include "base/tools/Chrono.h" -#include "common/net/SubmitResult.h" xmrig::NetworkState::NetworkState() : diff --git a/src/common/interfaces/IClientListener.h b/src/base/kernel/interfaces/IClientListener.h similarity index 100% rename from src/common/interfaces/IClientListener.h rename to src/base/kernel/interfaces/IClientListener.h diff --git a/src/common/interfaces/IStrategy.h b/src/base/kernel/interfaces/IStrategy.h similarity index 100% rename from src/common/interfaces/IStrategy.h rename to src/base/kernel/interfaces/IStrategy.h diff --git a/src/common/interfaces/IStrategyListener.h b/src/base/kernel/interfaces/IStrategyListener.h similarity index 100% rename from src/common/interfaces/IStrategyListener.h rename to src/base/kernel/interfaces/IStrategyListener.h diff --git a/src/common/net/Client.cpp b/src/base/net/stratum/Client.cpp similarity index 99% rename from src/common/net/Client.cpp rename to src/base/net/stratum/Client.cpp index 59ad69b0b..1dfbc7fd5 100644 --- a/src/common/net/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -33,14 +33,14 @@ #ifndef XMRIG_NO_TLS # include # include -# include "common/net/Tls.h" +# include "base/net/stratum/Tls.h" #endif +#include "base/kernel/interfaces/IClientListener.h" +#include "base/net/stratum/Client.h" #include "base/tools/Chrono.h" -#include "common/interfaces/IClientListener.h" #include "common/log/Log.h" -#include "common/net/Client.h" #include "net/JobResult.h" #include "rapidjson/document.h" #include "rapidjson/error/en.h" diff --git a/src/common/net/Client.h b/src/base/net/stratum/Client.h similarity index 97% rename from src/common/net/Client.h rename to src/base/net/stratum/Client.h index c46395199..977a3681f 100644 --- a/src/common/net/Client.h +++ b/src/base/net/stratum/Client.h @@ -32,12 +32,12 @@ #include -#include "base/net/Pool.h" +#include "base/net/stratum/Id.h" +#include "base/net/stratum/Job.h" +#include "base/net/stratum/Pool.h" +#include "base/net/stratum/SubmitResult.h" +#include "base/net/tools/Storage.h" #include "common/crypto/Algorithm.h" -#include "common/net/Id.h" -#include "common/net/Job.h" -#include "common/net/Storage.h" -#include "common/net/SubmitResult.h" #include "rapidjson/fwd.h" diff --git a/src/common/net/Id.h b/src/base/net/stratum/Id.h similarity index 100% rename from src/common/net/Id.h rename to src/base/net/stratum/Id.h diff --git a/src/common/net/Job.cpp b/src/base/net/stratum/Job.cpp similarity index 99% rename from src/common/net/Job.cpp rename to src/base/net/stratum/Job.cpp index 851507adc..3fb691ced 100644 --- a/src/common/net/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -28,7 +28,7 @@ #include -#include "common/net/Job.h" +#include "base/net/stratum/Job.h" unsigned char hf_hex2bin(char c, bool &err) diff --git a/src/common/net/Job.h b/src/base/net/stratum/Job.h similarity index 99% rename from src/common/net/Job.h rename to src/base/net/stratum/Job.h index a6e1ec257..426a64ded 100644 --- a/src/common/net/Job.h +++ b/src/base/net/stratum/Job.h @@ -32,7 +32,7 @@ #include "common/crypto/Algorithm.h" -#include "common/net/Id.h" +#include "base/net/stratum/Id.h" namespace xmrig { diff --git a/src/base/net/Pool.cpp b/src/base/net/stratum/Pool.cpp similarity index 99% rename from src/base/net/Pool.cpp rename to src/base/net/stratum/Pool.cpp index de02be92c..f371b4c07 100644 --- a/src/base/net/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -30,7 +30,7 @@ #include "base/io/Json.h" -#include "base/net/Pool.h" +#include "base/net/stratum/Pool.h" #include "rapidjson/document.h" diff --git a/src/base/net/Pool.h b/src/base/net/stratum/Pool.h similarity index 100% rename from src/base/net/Pool.h rename to src/base/net/stratum/Pool.h diff --git a/src/base/net/Pools.cpp b/src/base/net/stratum/Pools.cpp similarity index 97% rename from src/base/net/Pools.cpp rename to src/base/net/stratum/Pools.cpp index e3b86acac..ba55e94b1 100644 --- a/src/base/net/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -23,10 +23,10 @@ */ -#include "base/net/Pools.h" +#include "base/net/stratum/Pools.h" +#include "base/net/stratum/strategies/FailoverStrategy.h" +#include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "common/log/Log.h" -#include "common/net/strategies/FailoverStrategy.h" -#include "common/net/strategies/SinglePoolStrategy.h" #include "rapidjson/document.h" diff --git a/src/base/net/Pools.h b/src/base/net/stratum/Pools.h similarity index 98% rename from src/base/net/Pools.h rename to src/base/net/stratum/Pools.h index a6038a044..0f856c695 100644 --- a/src/base/net/Pools.h +++ b/src/base/net/stratum/Pools.h @@ -29,7 +29,7 @@ #include -#include "base/net/Pool.h" +#include "base/net/stratum/Pool.h" namespace xmrig { diff --git a/src/common/net/SubmitResult.cpp b/src/base/net/stratum/SubmitResult.cpp similarity index 97% rename from src/common/net/SubmitResult.cpp rename to src/base/net/stratum/SubmitResult.cpp index d14bbb408..ad8a48af0 100644 --- a/src/common/net/SubmitResult.cpp +++ b/src/base/net/stratum/SubmitResult.cpp @@ -26,7 +26,7 @@ #include -#include "common/net/SubmitResult.h" +#include "base/net/stratum/SubmitResult.h" xmrig::SubmitResult::SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId) : diff --git a/src/common/net/SubmitResult.h b/src/base/net/stratum/SubmitResult.h similarity index 100% rename from src/common/net/SubmitResult.h rename to src/base/net/stratum/SubmitResult.h diff --git a/src/common/net/Tls.cpp b/src/base/net/stratum/Tls.cpp similarity index 98% rename from src/common/net/Tls.cpp rename to src/base/net/stratum/Tls.cpp index a9b3fa7de..04aeae92c 100644 --- a/src/common/net/Tls.cpp +++ b/src/base/net/stratum/Tls.cpp @@ -27,8 +27,8 @@ #include -#include "common/net/Client.h" -#include "common/net/Tls.h" +#include "base/net/stratum/Client.h" +#include "base/net/stratum/Tls.h" #include "common/log/Log.h" diff --git a/src/common/net/Tls.h b/src/base/net/stratum/Tls.h similarity index 98% rename from src/common/net/Tls.h rename to src/base/net/stratum/Tls.h index cce78eeb4..e070be526 100644 --- a/src/common/net/Tls.h +++ b/src/base/net/stratum/Tls.h @@ -29,7 +29,7 @@ #include -#include "common/net/Client.h" +#include "base/net/stratum/Client.h" namespace xmrig { diff --git a/src/common/net/strategies/FailoverStrategy.cpp b/src/base/net/stratum/strategies/FailoverStrategy.cpp similarity index 96% rename from src/common/net/strategies/FailoverStrategy.cpp rename to src/base/net/stratum/strategies/FailoverStrategy.cpp index 1ec7449f9..d2e4a6da3 100644 --- a/src/common/net/strategies/FailoverStrategy.cpp +++ b/src/base/net/stratum/strategies/FailoverStrategy.cpp @@ -23,9 +23,9 @@ */ -#include "common/interfaces/IStrategyListener.h" -#include "common/net/Client.h" -#include "common/net/strategies/FailoverStrategy.h" +#include "base/kernel/interfaces/IStrategyListener.h" +#include "base/net/stratum/Client.h" +#include "base/net/stratum/strategies/FailoverStrategy.h" #include "common/Platform.h" diff --git a/src/common/net/strategies/FailoverStrategy.h b/src/base/net/stratum/strategies/FailoverStrategy.h similarity index 95% rename from src/common/net/strategies/FailoverStrategy.h rename to src/base/net/stratum/strategies/FailoverStrategy.h index a02b590e4..3517de9d1 100644 --- a/src/common/net/strategies/FailoverStrategy.h +++ b/src/base/net/stratum/strategies/FailoverStrategy.h @@ -29,9 +29,9 @@ #include -#include "base/net/Pool.h" -#include "common/interfaces/IClientListener.h" -#include "common/interfaces/IStrategy.h" +#include "base/kernel/interfaces/IClientListener.h" +#include "base/kernel/interfaces/IStrategy.h" +#include "base/net/stratum/Pool.h" namespace xmrig { diff --git a/src/common/net/strategies/SinglePoolStrategy.cpp b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp similarity index 95% rename from src/common/net/strategies/SinglePoolStrategy.cpp rename to src/base/net/stratum/strategies/SinglePoolStrategy.cpp index ca5d45f73..b81594e14 100644 --- a/src/common/net/strategies/SinglePoolStrategy.cpp +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.cpp @@ -23,9 +23,9 @@ */ -#include "common/interfaces/IStrategyListener.h" -#include "common/net/Client.h" -#include "common/net/strategies/SinglePoolStrategy.h" +#include "base/kernel/interfaces/IStrategyListener.h" +#include "base/net/stratum/Client.h" +#include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "common/Platform.h" diff --git a/src/common/net/strategies/SinglePoolStrategy.h b/src/base/net/stratum/strategies/SinglePoolStrategy.h similarity index 96% rename from src/common/net/strategies/SinglePoolStrategy.h rename to src/base/net/stratum/strategies/SinglePoolStrategy.h index 7d864263e..5b3016c13 100644 --- a/src/common/net/strategies/SinglePoolStrategy.h +++ b/src/base/net/stratum/strategies/SinglePoolStrategy.h @@ -26,8 +26,8 @@ #define XMRIG_SINGLEPOOLSTRATEGY_H -#include "common/interfaces/IClientListener.h" -#include "common/interfaces/IStrategy.h" +#include "base/kernel/interfaces/IClientListener.h" +#include "base/kernel/interfaces/IStrategy.h" namespace xmrig { diff --git a/src/common/net/Storage.h b/src/base/net/tools/Storage.h similarity index 70% rename from src/common/net/Storage.h rename to src/base/net/tools/Storage.h index f36ce5946..aff624816 100644 --- a/src/common/net/Storage.h +++ b/src/base/net/tools/Storage.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-2019 SChernykh + * Copyright 2016-2019 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 __STORAGE_H__ -#define __STORAGE_H__ +#ifndef XMRIG_STORAGE_H +#define XMRIG_STORAGE_H #include @@ -53,11 +54,10 @@ public: inline static void *ptr(uintptr_t id) { return reinterpret_cast(id); } - inline TYPE *get(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); - if (m_data.count(id) == 0) { return nullptr; } @@ -66,20 +66,22 @@ public: } - inline void remove(void *id) { remove(reinterpret_cast(id)); } - inline void remove(uintptr_t 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(uintptr_t id) { TYPE *obj = get(id); - if (obj == nullptr) { - return; + if (obj != nullptr) { + auto it = m_data.find(id); + if (it != m_data.end()) { + m_data.erase(it); + } } - auto it = m_data.find(id); - if (it != m_data.end()) { - m_data.erase(it); - } - - delete obj; + return obj; } @@ -92,4 +94,4 @@ private: } /* namespace xmrig */ -#endif /* __STORAGE_H__ */ +#endif /* XMRIG_STORAGE_H */ diff --git a/src/common/config/CommonConfig.h b/src/common/config/CommonConfig.h index 103e69d24..729c24510 100644 --- a/src/common/config/CommonConfig.h +++ b/src/common/config/CommonConfig.h @@ -26,7 +26,7 @@ #define XMRIG_COMMONCONFIG_H -#include "base/net/Pools.h" +#include "base/net/stratum/Pools.h" #include "base/tools/String.h" #include "common/interfaces/IConfig.h" #include "common/xmrig.h" diff --git a/src/net/JobResult.h b/src/net/JobResult.h index 5ab4d2942..2e5b08688 100644 --- a/src/net/JobResult.h +++ b/src/net/JobResult.h @@ -31,7 +31,7 @@ #include -#include "common/net/Job.h" +#include "base/net/stratum/Job.h" namespace xmrig { diff --git a/src/net/Network.cpp b/src/net/Network.cpp index 6822ad32b..b8f4f05e7 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -32,10 +32,10 @@ #include "api/Api.h" +#include "base/net/stratum/Client.h" +#include "base/net/stratum/SubmitResult.h" #include "base/tools/Chrono.h" #include "common/log/Log.h" -#include "common/net/Client.h" -#include "common/net/SubmitResult.h" #include "core/Config.h" #include "core/Controller.h" #include "net/Network.h" diff --git a/src/net/Network.h b/src/net/Network.h index 5a5cbc3ef..8796045a2 100644 --- a/src/net/Network.h +++ b/src/net/Network.h @@ -31,8 +31,8 @@ #include "api/NetworkState.h" +#include "base/kernel/interfaces/IStrategyListener.h" #include "common/interfaces/IControllerListener.h" -#include "common/interfaces/IStrategyListener.h" #include "interfaces/IJobResultListener.h" diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index 9593dc9a8..f056d498c 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -23,12 +23,11 @@ */ +#include "base/net/stratum/Client.h" +#include "base/net/stratum/Job.h" +#include "base/net/stratum/strategies/FailoverStrategy.h" +#include "base/net/stratum/strategies/SinglePoolStrategy.h" #include "common/crypto/keccak.h" -#include "common/interfaces/IStrategyListener.h" -#include "common/net/Client.h" -#include "common/net/Job.h" -#include "common/net/strategies/FailoverStrategy.h" -#include "common/net/strategies/SinglePoolStrategy.h" #include "common/Platform.h" #include "common/xmrig.h" #include "net/strategies/DonateStrategy.h" diff --git a/src/net/strategies/DonateStrategy.h b/src/net/strategies/DonateStrategy.h index 76702ef32..8c350097e 100644 --- a/src/net/strategies/DonateStrategy.h +++ b/src/net/strategies/DonateStrategy.h @@ -30,10 +30,10 @@ #include -#include "base/net/Pool.h" -#include "common/interfaces/IClientListener.h" -#include "common/interfaces/IStrategy.h" -#include "common/interfaces/IStrategyListener.h" +#include "base/kernel/interfaces/IClientListener.h" +#include "base/kernel/interfaces/IStrategy.h" +#include "base/kernel/interfaces/IStrategyListener.h" +#include "base/net/stratum/Pool.h" namespace xmrig { diff --git a/src/workers/MultiWorker.h b/src/workers/MultiWorker.h index b7e4c8cae..525eee18c 100644 --- a/src/workers/MultiWorker.h +++ b/src/workers/MultiWorker.h @@ -27,7 +27,7 @@ #define XMRIG_MULTIWORKER_H -#include "common/net/Job.h" +#include "base/net/stratum/Job.h" #include "Mem.h" #include "net/JobResult.h" #include "workers/Worker.h" diff --git a/src/workers/Workers.h b/src/workers/Workers.h index a9b8e6958..0760c98f3 100644 --- a/src/workers/Workers.h +++ b/src/workers/Workers.h @@ -31,7 +31,7 @@ #include #include -#include "common/net/Job.h" +#include "base/net/stratum/Job.h" #include "net/JobResult.h" #include "rapidjson/fwd.h"