Merge xmrig v6.4.0 into master
This commit is contained in:
commit
2cf2fcaf8c
109 changed files with 7365 additions and 6359 deletions
|
@ -127,6 +127,7 @@ elseif (APPLE)
|
|||
)
|
||||
else()
|
||||
set(SOURCES_OS
|
||||
src/base/io/Async.cpp
|
||||
src/base/io/json/Json_unix.cpp
|
||||
src/base/kernel/Platform_unix.cpp
|
||||
)
|
||||
|
@ -226,11 +227,16 @@ endif()
|
|||
if (WITH_PROFILING)
|
||||
add_definitions(/DXMRIG_FEATURE_PROFILING)
|
||||
|
||||
list(APPEND HEADERS_BASE
|
||||
src/base/tools/Profiler.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BASE
|
||||
src/base/tools/Profiler.cpp
|
||||
)
|
||||
list(APPEND HEADERS_BASE src/base/tools/Profiler.h)
|
||||
list(APPEND SOURCES_BASE src/base/tools/Profiler.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
if (WITH_RANDOMX AND WITH_BENCHMARK)
|
||||
add_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||
|
||||
list(APPEND HEADERS_BASE src/base/net/stratum/NullClient.h)
|
||||
list(APPEND SOURCES_BASE src/base/net/stratum/NullClient.cpp)
|
||||
else()
|
||||
remove_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||
endif()
|
||||
|
|
|
@ -105,8 +105,6 @@ static AlgoName const algorithm_names[] = {
|
|||
{ "RandomX", "rx", Algorithm::RX_0 },
|
||||
{ "randomx/wow", "rx/wow", Algorithm::RX_WOW },
|
||||
{ "RandomWOW", nullptr, Algorithm::RX_WOW },
|
||||
{ "randomx/loki", "rx/loki", Algorithm::RX_LOKI },
|
||||
{ "RandomXL", nullptr, Algorithm::RX_LOKI },
|
||||
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
||||
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
||||
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
|
||||
|
@ -121,6 +119,8 @@ static AlgoName const algorithm_names[] = {
|
|||
# ifdef XMRIG_ALGO_ARGON2
|
||||
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||
{ "chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||
{ "argon2/chukwav2", nullptr, Algorithm::AR2_CHUKWA_V2 },
|
||||
{ "chukwav2", nullptr, Algorithm::AR2_CHUKWA_V2 },
|
||||
{ "argon2/wrkz", nullptr, Algorithm::AR2_WRKZ },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
|
@ -168,7 +168,6 @@ size_t xmrig::Algorithm::l2() const
|
|||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_LOKI:
|
||||
case RX_SFX:
|
||||
return 0x40000;
|
||||
|
||||
|
@ -218,7 +217,6 @@ size_t xmrig::Algorithm::l3() const
|
|||
if (f == RANDOM_X) {
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_LOKI:
|
||||
case RX_SFX:
|
||||
return oneMiB * 2;
|
||||
|
||||
|
@ -243,6 +241,9 @@ size_t xmrig::Algorithm::l3() const
|
|||
case AR2_CHUKWA:
|
||||
return oneMiB / 2;
|
||||
|
||||
case AR2_CHUKWA_V2:
|
||||
return oneMiB;
|
||||
|
||||
case AR2_WRKZ:
|
||||
return oneMiB / 4;
|
||||
|
||||
|
@ -352,7 +353,6 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
|||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
case RX_0:
|
||||
case RX_WOW:
|
||||
case RX_LOKI:
|
||||
case RX_ARQ:
|
||||
case RX_SFX:
|
||||
case RX_KEVA:
|
||||
|
@ -363,6 +363,7 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
|||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
case AR2_CHUKWA:
|
||||
case AR2_CHUKWA_V2:
|
||||
case AR2_WRKZ:
|
||||
return ARGON2;
|
||||
# endif
|
||||
|
|
|
@ -69,11 +69,11 @@ public:
|
|||
// next line MUST be RX_0
|
||||
RX_0, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_LOKI, // "rx/loki" RandomXL (Loki).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_SFX, // "rx/sfx" RandomSFX (Safex Cash).
|
||||
RX_KEVA, // "rx/keva" RandomKEVA (Keva).
|
||||
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
||||
AR2_CHUKWA_V2, // "argon2/chukwav2" Argon2id (Chukwa v2).
|
||||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero)
|
||||
KAWPOW_RVN, // "kawpow/rvn" KawPow (RVN)
|
||||
|
|
98
src/base/io/Async.cpp
Normal file
98
src/base/io/Async.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2015-2020 libuv project contributors.
|
||||
* Copyright (c) 2020 cohcho <https://github.com/cohcho>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "base/io/Async.h"
|
||||
|
||||
|
||||
#if defined(XMRIG_UV_PERFORMANCE_BUG)
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/poll.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
uv_async_t::~uv_async_t()
|
||||
{
|
||||
close(m_fd);
|
||||
}
|
||||
|
||||
|
||||
static void on_schedule(uv_poll_t *handle, int status, int events)
|
||||
{
|
||||
static uint64_t val;
|
||||
uv_async_t *async = reinterpret_cast<uv_async_t *>(handle);
|
||||
for (;;) {
|
||||
int r = read(async->m_fd, &val, sizeof(val));
|
||||
|
||||
if (r == sizeof(val))
|
||||
continue;
|
||||
|
||||
if (r != -1)
|
||||
break;
|
||||
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
break;
|
||||
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
abort();
|
||||
}
|
||||
if (async->m_cb) {
|
||||
(*async->m_cb)(async);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int uv_async_init(uv_loop_t *loop, uv_async_t *async, uv_async_cb cb)
|
||||
{
|
||||
int fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
return uv_translate_sys_error(errno);
|
||||
}
|
||||
uv_poll_init(loop, (uv_poll_t *)async, fd);
|
||||
uv_poll_start((uv_poll_t *)async, POLLIN, on_schedule);
|
||||
async->m_cb = cb;
|
||||
async->m_fd = fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_async_send(uv_async_t *async)
|
||||
{
|
||||
static const uint64_t val = 1;
|
||||
int r;
|
||||
do {
|
||||
r = write(async->m_fd, &val, sizeof(val));
|
||||
}
|
||||
while (r == -1 && errno == EINTR);
|
||||
if (r == sizeof(val) || (r == 1 && (errno == EAGAIN || errno == EWOULDBLOCK))) {
|
||||
return 0;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
#endif
|
52
src/base/io/Async.h
Normal file
52
src/base/io/Async.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2015-2020 libuv project contributors.
|
||||
* Copyright (c) 2020 cohcho <https://github.com/cohcho>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ASYNC_H
|
||||
#define XMRIG_ASYNC_H
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
// since 2019.05.16, Version 1.29.0 (Stable)
|
||||
#if (UV_VERSION_MAJOR >= 1) && (UV_VERSION_MINOR >= 29) && defined(__linux__)
|
||||
#define XMRIG_UV_PERFORMANCE_BUG
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
struct uv_async_t: uv_poll_t
|
||||
{
|
||||
typedef void (*uv_async_cb)(uv_async_t* handle);
|
||||
~uv_async_t();
|
||||
int m_fd = -1;
|
||||
uv_async_cb m_cb = nullptr;
|
||||
};
|
||||
|
||||
|
||||
using uv_async_cb = uv_async_t::uv_async_cb;
|
||||
extern int uv_async_init(uv_loop_t *loop, uv_async_t *async, uv_async_cb cb);
|
||||
extern int uv_async_send(uv_async_t *async);
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* XMRIG_ASYNC_H */
|
|
@ -104,6 +104,7 @@ private:
|
|||
#define WHITE_BOLD_S CSI "1;37m" // actually white
|
||||
|
||||
#define BRIGHT_BLACK_BG_S CSI "100m" // somewhat MD.GRAY
|
||||
#define RED_BG_BOLD_S CSI "41;1m"
|
||||
#define GREEN_BG_BOLD_S CSI "42;1m"
|
||||
#define YELLOW_BG_BOLD_S CSI "43;1m"
|
||||
#define BLUE_BG_S CSI "44m"
|
||||
|
@ -132,6 +133,7 @@ private:
|
|||
#define WHITE_BOLD(x) WHITE_BOLD_S x CLEAR
|
||||
|
||||
#define BRIGHT_BLACK_BG(x) BRIGHT_BLACK_BG_S x CLEAR
|
||||
#define RED_BG_BOLD(x) RED_BG_BOLD_S x CLEAR
|
||||
#define GREEN_BG_BOLD(x) GREEN_BG_BOLD_S x CLEAR
|
||||
#define YELLOW_BG_BOLD(x) YELLOW_BG_BOLD_S x CLEAR
|
||||
#define BLUE_BG(x) BLUE_BG_S x CLEAR
|
||||
|
|
|
@ -70,6 +70,16 @@ const char *xmrig::Tags::randomx()
|
|||
return tag;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *xmrig::Tags::bench()
|
||||
{
|
||||
static const char *tag = GREEN_BG_BOLD(WHITE_BOLD_S " bench ");
|
||||
|
||||
return tag;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
static const char *randomx();
|
||||
# endif
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *bench();
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
|
|
|
@ -151,7 +151,9 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
}
|
||||
break;
|
||||
|
||||
case IConfig::UrlKey: /* --url */
|
||||
case IConfig::UrlKey: /* --url */
|
||||
case IConfig::StressKey: /* --stress */
|
||||
case IConfig::BenchKey: /* --bench */
|
||||
{
|
||||
if (!doc.HasMember(Pools::kPools)) {
|
||||
doc.AddMember(rapidjson::StringRef(Pools::kPools), rapidjson::kArrayType, doc.GetAllocator());
|
||||
|
@ -162,7 +164,20 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
array.PushBack(rapidjson::kObjectType, doc.GetAllocator());
|
||||
}
|
||||
|
||||
set(doc, array[array.Size() - 1], Pool::kUrl, arg);
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (key != IConfig::UrlKey) {
|
||||
set(doc, array[array.Size() - 1], Pool::kUrl, (key == IConfig::BenchKey) ? "benchmark" :
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
"stratum+ssl://randomx.xmrig.com:443"
|
||||
# else
|
||||
"randomx.xmrig.com:3333"
|
||||
# endif
|
||||
);
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
set(doc, array[array.Size() - 1], Pool::kUrl, arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
TitleKey = 1037,
|
||||
NoTitleKey = 1038,
|
||||
PauseOnBatteryKey = 1041,
|
||||
StressKey = 1042,
|
||||
BenchKey = 1043,
|
||||
|
||||
// xmrig common
|
||||
CPUPriorityKey = 1021,
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
62
src/base/net/stratum/NullClient.cpp
Normal file
62
src/base/net/stratum/NullClient.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "base/net/stratum/NullClient.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
|
||||
|
||||
xmrig::NullClient::NullClient(IClientListener* listener) :
|
||||
m_listener(listener)
|
||||
{
|
||||
m_job.setAlgorithm(Algorithm::RX_0);
|
||||
|
||||
std::vector<char> blob(112 * 2 + 1, '0');
|
||||
|
||||
blob.back() = '\0';
|
||||
m_job.setBlob(blob.data());
|
||||
|
||||
blob[Job::kMaxSeedSize * 2] = '\0';
|
||||
m_job.setSeedHash(blob.data());
|
||||
|
||||
m_job.setDiff(uint64_t(-1));
|
||||
m_job.setHeight(1);
|
||||
|
||||
m_job.setId("00000000");
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NullClient::connect()
|
||||
{
|
||||
m_listener->onLoginSuccess(this);
|
||||
|
||||
rapidjson::Value params;
|
||||
m_listener->onJobReceived(this, m_job, params);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NullClient::setPool(const Pool& pool)
|
||||
{
|
||||
m_pool = pool;
|
||||
|
||||
if (!m_pool.algorithm().isValid()) {
|
||||
m_pool.setAlgo(Algorithm::RX_0);
|
||||
}
|
||||
|
||||
m_job.setAlgorithm(m_pool.algorithm().id());
|
||||
}
|
77
src/base/net/stratum/NullClient.h
Normal file
77
src/base/net/stratum/NullClient.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_NULLCLIENT_H
|
||||
#define XMRIG_NULLCLIENT_H
|
||||
|
||||
|
||||
#include "base/net/stratum/Client.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class NullClient : public IClient
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(NullClient)
|
||||
|
||||
NullClient(IClientListener* listener);
|
||||
~NullClient() override = default;
|
||||
|
||||
inline bool disconnect() override { return true; }
|
||||
inline bool hasExtension(Extension extension) const noexcept override { return false; }
|
||||
inline bool isEnabled() const override { return true; }
|
||||
inline bool isTLS() const override { return false; }
|
||||
inline const char *mode() const override { return "benchmark"; }
|
||||
inline const char *tag() const override { return "null"; }
|
||||
inline const char *tlsFingerprint() const override { return nullptr; }
|
||||
inline const char *tlsVersion() const override { return nullptr; }
|
||||
inline const Job &job() const override { return m_job; }
|
||||
inline const Pool &pool() const override { return m_pool; }
|
||||
inline const String &ip() const override { return m_ip; }
|
||||
inline int id() const override { return 0; }
|
||||
inline int64_t send(const rapidjson::Value& obj, Callback callback) override { return 0; }
|
||||
inline int64_t send(const rapidjson::Value& obj) override { return 0; }
|
||||
inline int64_t sequence() const override { return 0; }
|
||||
inline int64_t submit(const JobResult& result) override { return 0; }
|
||||
inline void connect(const Pool& pool) override { setPool(pool); }
|
||||
inline void deleteLater() override {}
|
||||
inline void setAlgo(const Algorithm& algo) override {}
|
||||
inline void setEnabled(bool enabled) override {}
|
||||
inline void setProxy(const ProxyUrl& proxy) override {}
|
||||
inline void setQuiet(bool quiet) override {}
|
||||
inline void setRetries(int retries) override {}
|
||||
inline void setRetryPause(uint64_t ms) override {}
|
||||
inline void tick(uint64_t now) override {}
|
||||
|
||||
void connect() override;
|
||||
void setPool(const Pool& pool) override;
|
||||
|
||||
private:
|
||||
IClientListener* m_listener;
|
||||
Job m_job;
|
||||
Pool m_pool;
|
||||
String m_ip;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_NULLCLIENT_H */
|
|
@ -50,6 +50,16 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
# include "base/net/stratum/NullClient.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -72,9 +82,11 @@ const char *Pool::kSOCKS5 = "socks5";
|
|||
const char *Pool::kTls = "tls";
|
||||
const char *Pool::kUrl = "url";
|
||||
const char *Pool::kUser = "user";
|
||||
const char *Pool::kNicehashHost = "nicehash.com";
|
||||
|
||||
|
||||
const char *Pool::kNicehashHost = "nicehash.com";
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
const char *Pool::kBenchmark = "benchmark";
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
@ -125,20 +137,22 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
|
|||
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash) || m_url.host().contains(kNicehashHost));
|
||||
m_flags.set(FLAG_TLS, Json::getBool(object, kTls) || m_url.isTLS());
|
||||
|
||||
setKeepAlive(Json::getValue(object, kKeepalive));
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (setBenchSize(Json::getString(object, kBenchmark, nullptr))) {
|
||||
m_mode = MODE_BENCHMARK;
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (m_daemon.isValid()) {
|
||||
m_mode = MODE_SELF_SELECT;
|
||||
}
|
||||
else if (Json::getBool(object, kDaemon)) {
|
||||
m_mode = MODE_DAEMON;
|
||||
}
|
||||
|
||||
const rapidjson::Value &keepalive = Json::getValue(object, kKeepalive);
|
||||
if (keepalive.IsInt()) {
|
||||
setKeepAlive(keepalive.GetInt());
|
||||
}
|
||||
else if (keepalive.IsBool()) {
|
||||
setKeepAlive(keepalive.GetBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,6 +231,11 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
|
|||
client = new AutoClient(id, Platform::userAgent(), listener);
|
||||
}
|
||||
# endif
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
else if (m_mode == MODE_BENCHMARK) {
|
||||
client = new NullClient(listener);
|
||||
}
|
||||
# endif
|
||||
|
||||
assert(client != nullptr);
|
||||
|
||||
|
@ -307,3 +326,34 @@ void xmrig::Pool::print() const
|
|||
LOG_DEBUG ("keepAlive: %d", m_keepAlive);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void xmrig::Pool::setKeepAlive(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsInt()) {
|
||||
setKeepAlive(value.GetInt());
|
||||
}
|
||||
else if (value.IsBool()) {
|
||||
setKeepAlive(value.GetBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||
bool xmrig::Pool::setBenchSize(const char *benchmark)
|
||||
{
|
||||
if (!benchmark) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto size = strtoul(benchmark, nullptr, 10);
|
||||
if (size < 1 || size > 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string s = std::to_string(size) + "M";
|
||||
m_benchSize = strcasecmp(benchmark, s.c_str()) == 0 ? size * 1000000 : 0;
|
||||
|
||||
return m_benchSize > 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,10 @@ public:
|
|||
MODE_POOL,
|
||||
MODE_DAEMON,
|
||||
MODE_SELF_SELECT,
|
||||
MODE_AUTO_ETH
|
||||
MODE_AUTO_ETH,
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
MODE_BENCHMARK,
|
||||
# endif
|
||||
};
|
||||
|
||||
static const String kDefaultPassword;
|
||||
|
@ -73,6 +76,10 @@ public:
|
|||
static const char *kUser;
|
||||
static const char *kNicehashHost;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
static const char *kBenchmark;
|
||||
# endif
|
||||
|
||||
constexpr static int kKeepAliveTimeout = 60;
|
||||
constexpr static uint16_t kDefaultPort = 3333;
|
||||
constexpr static uint64_t kDefaultPollInterval = 1000;
|
||||
|
@ -105,6 +112,10 @@ public:
|
|||
inline void setRigId(const String &rigId) { m_rigId = rigId; }
|
||||
inline void setUser(const String &user) { m_user = user; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
inline uint32_t benchSize() const { return m_benchSize; }
|
||||
# endif
|
||||
|
||||
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Pool &other) const { return isEqual(other); }
|
||||
|
||||
|
@ -129,6 +140,8 @@ private:
|
|||
inline void setKeepAlive(bool enable) { setKeepAlive(enable ? kKeepAliveTimeout : 0); }
|
||||
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
|
||||
|
||||
void setKeepAlive(const rapidjson::Value &value);
|
||||
|
||||
Algorithm m_algorithm;
|
||||
Coin m_coin;
|
||||
int m_keepAlive = 0;
|
||||
|
@ -142,6 +155,12 @@ private:
|
|||
uint64_t m_pollInterval = kDefaultPollInterval;
|
||||
Url m_daemon;
|
||||
Url m_url;
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
bool setBenchSize(const char *benchmark);
|
||||
|
||||
uint32_t m_benchSize = 0;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -144,6 +144,18 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
|||
}
|
||||
|
||||
|
||||
uint32_t xmrig::Pools::benchSize() const
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_data.size() == 1 && m_data.front().mode() == Pool::MODE_BENCHMARK) {
|
||||
return m_data.front().benchSize();
|
||||
}
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Pools::print() const
|
||||
{
|
||||
size_t i = 1;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
Pools();
|
||||
|
||||
inline const std::vector<Pool> &data() const { return m_data; }
|
||||
inline int donateLevel() const { return m_donateLevel; }
|
||||
inline int donateLevel() const { return benchSize() ? 0 : m_donateLevel; }
|
||||
inline int retries() const { return m_retries; }
|
||||
inline int retryPause() const { return m_retryPause; }
|
||||
inline ProxyDonate proxyDonate() const { return m_proxyDonate; }
|
||||
|
@ -70,6 +70,7 @@ public:
|
|||
IStrategy *createStrategy(IStrategyListener *listener) const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t active() const;
|
||||
uint32_t benchSize() const;
|
||||
void load(const IJsonReader &reader);
|
||||
void print() const;
|
||||
|
||||
|
|
|
@ -38,12 +38,7 @@ void xmrig::LineReader::parse(char *data, size_t size)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_buf) {
|
||||
return getline(data, size);
|
||||
}
|
||||
|
||||
add(data, size);
|
||||
getline(m_buf, m_pos);
|
||||
getline(data, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +55,7 @@ void xmrig::LineReader::reset()
|
|||
void xmrig::LineReader::add(const char *data, size_t size)
|
||||
{
|
||||
if (size > NetBuffer::kChunkSize - m_pos) {
|
||||
// it breakes correctness silently for long lines
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,7 +81,12 @@ void xmrig::LineReader::getline(char *data, size_t size)
|
|||
end++;
|
||||
|
||||
const auto len = static_cast<size_t>(end - start);
|
||||
if (len > 1) {
|
||||
if (m_pos) {
|
||||
add(start, len);
|
||||
m_listener->onLine(m_buf, m_pos - 1);
|
||||
m_pos = 0;
|
||||
}
|
||||
else if (len > 1) {
|
||||
m_listener->onLine(start, len - 1);
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,5 @@ void xmrig::LineReader::getline(char *data, size_t size)
|
|||
return reset();
|
||||
}
|
||||
|
||||
if (!m_buf || m_buf != data) {
|
||||
add(start, remaining);
|
||||
}
|
||||
add(start, remaining);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue