From 2ecf10cdcb98eb3a47bbd515eaea8a9097f46d27 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 6 Aug 2023 20:26:07 +0700 Subject: [PATCH] Make Platform::hasKeepalive() constexpr where always supported and code cleanup. --- src/base/kernel/Platform.h | 8 ++++++-- src/base/kernel/Platform_mac.cpp | 6 ------ src/base/kernel/Platform_unix.cpp | 6 ------ src/base/kernel/Platform_win.cpp | 5 ++--- src/base/net/stratum/Client.cpp | 8 ++++---- src/base/net/stratum/DaemonClient.cpp | 23 +++++++++++------------ 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/base/kernel/Platform.h b/src/base/kernel/Platform.h index b63a65fb4..9e713d031 100644 --- a/src/base/kernel/Platform.h +++ b/src/base/kernel/Platform.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -49,7 +49,11 @@ public: static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; } static inline const String &userAgent() { return m_userAgent; } +# ifdef XMRIG_OS_WIN static bool hasKeepalive(); +# else + static constexpr bool hasKeepalive() { return true; } +# endif static bool isOnBatteryPower(); static uint64_t idleTime(); diff --git a/src/base/kernel/Platform_mac.cpp b/src/base/kernel/Platform_mac.cpp index 8420d1289..d07e925d4 100644 --- a/src/base/kernel/Platform_mac.cpp +++ b/src/base/kernel/Platform_mac.cpp @@ -55,12 +55,6 @@ char *xmrig::Platform::createUserAgent() } -bool xmrig::Platform::hasKeepalive() -{ - return true; -} - - bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) { return true; diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index 43e8a742f..4ffee2140 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -70,12 +70,6 @@ char *xmrig::Platform::createUserAgent() } -bool xmrig::Platform::hasKeepalive() -{ - return true; -} - - #ifndef XMRIG_FEATURE_HWLOC #ifdef __DragonFly__ diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index ee04ee2a4..94d1282e7 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include #include #include diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index d780a5a8a..4dffd2173 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 jtgrassie - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -42,15 +42,15 @@ #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IClientListener.h" +#include "base/kernel/Platform.h" #include "base/net/dns/Dns.h" #include "base/net/dns/DnsRecords.h" #include "base/net/stratum/Socks5.h" #include "base/net/tools/NetBuffer.h" #include "base/tools/Chrono.h" -#include "base/tools/Cvt.h" #include "base/tools/cryptonote/BlobReader.h" +#include "base/tools/Cvt.h" #include "net/JobResult.h" -#include "base/kernel/Platform.h" #ifdef _MSC_VER diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 57d16685e..37f352bc1 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -1,13 +1,13 @@ /* 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 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright (c) 2010 Jeff Garzik + * Copyright (c) 2012-2014 pooler + * Copyright (c) 2014 Lucas Jones + * Copyright (c) 2014-2016 Wolf9466 + * Copyright (c) 2016 Jay D Dee + * Copyright (c) 2017-2018 XMR-Stak , + * Copyright (c) 2019 Howard Chu + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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,7 +23,6 @@ * along with this program. If not, see . */ - #include @@ -34,6 +33,7 @@ #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IClientListener.h" +#include "base/kernel/Platform.h" #include "base/net/dns/Dns.h" #include "base/net/dns/DnsRecords.h" #include "base/net/http/Fetch.h" @@ -42,11 +42,10 @@ #include "base/net/stratum/SubmitResult.h" #include "base/net/tools/NetBuffer.h" #include "base/tools/bswap_64.h" +#include "base/tools/cryptonote/Signatures.h" #include "base/tools/Cvt.h" #include "base/tools/Timer.h" -#include "base/tools/cryptonote/Signatures.h" #include "net/JobResult.h" -#include "base/kernel/Platform.h" #ifdef XMRIG_FEATURE_TLS