Merge of xmrig v6.5.0

This commit is contained in:
MoneroOcean 2020-11-02 15:08:16 +00:00
commit a57d1bbbda
86 changed files with 15293 additions and 490 deletions

View file

@ -34,6 +34,7 @@
#include "base/kernel/interfaces/IClientListener.h"
#include "base/net/http/Fetch.h"
#include "base/net/http/HttpData.h"
#include "base/net/http/HttpListener.h"
#include "base/net/stratum/SubmitResult.h"
#include "base/tools/Buffer.h"
#include "base/tools/Timer.h"

View file

@ -27,8 +27,8 @@
#define XMRIG_DAEMONCLIENT_H
#include "base/kernel/interfaces/IHttpListener.h"
#include "base/kernel/interfaces/ITimerListener.h"
#include "base/net/http/HttpListener.h"
#include "base/net/stratum/BaseClient.h"
#include "base/tools/Object.h"

View file

@ -174,6 +174,12 @@ void xmrig::Job::copy(const Job &other)
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
# endif
# ifdef XMRIG_FEATURE_BENCHMARK
m_benchSize = other.m_benchSize;
m_benchHash = other.m_benchHash;
m_benchToken = other.m_benchToken;
# endif
}
@ -205,4 +211,10 @@ void xmrig::Job::move(Job &&other)
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
# endif
# ifdef XMRIG_FEATURE_BENCHMARK
m_benchSize = other.m_benchSize;
m_benchHash = other.m_benchHash;
m_benchToken = std::move(other.m_benchToken);
# endif
}

View file

@ -82,7 +82,7 @@ public:
inline uint32_t backend() const { return m_backend; }
inline uint64_t diff() const { return m_diff; }
inline uint64_t height() const { return m_height; }
inline uint64_t nonceMask() const { return isNicehash() ? 0xFFFFFFULL : (nonceSize() == sizeof(uint64_t) ? (-1ull >> (extraNonce().size() * 4)): 0xFFFFFFFFULL); }
inline uint64_t nonceMask() const { return isNicehash() ? 0xFFFFFFULL : (nonceSize() == sizeof(uint64_t) ? (-1ULL >> (extraNonce().size() * 4)): 0xFFFFFFFFULL); }
inline uint64_t target() const { return m_target; }
inline uint8_t *blob() { return m_blob; }
inline uint8_t fixedByte() const { return *(m_blob + 42); }
@ -98,18 +98,27 @@ public:
inline void setPoolWallet(const String &poolWallet) { m_poolWallet = poolWallet; }
# ifdef XMRIG_PROXY_PROJECT
inline char *rawBlob() { return m_rawBlob; }
inline const char *rawBlob() const { return m_rawBlob; }
inline const char *rawTarget() const { return m_rawTarget; }
inline const String &rawSeedHash() const { return m_rawSeedHash; }
inline char *rawBlob() { return m_rawBlob; }
inline const char *rawBlob() const { return m_rawBlob; }
inline const char *rawTarget() const { return m_rawTarget; }
inline const String &rawSeedHash() const { return m_rawSeedHash; }
# endif
static inline uint64_t toDiff(uint64_t target) { return target ? (0xFFFFFFFFFFFFFFFFULL / target) : 0; }
static inline uint64_t toDiff(uint64_t target) { return target ? (0xFFFFFFFFFFFFFFFFULL / target) : 0; }
inline bool operator!=(const Job &other) const { return !isEqual(other); }
inline bool operator==(const Job &other) const { return isEqual(other); }
inline Job &operator=(const Job &other) { copy(other); return *this; }
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
inline bool operator!=(const Job &other) const { return !isEqual(other); }
inline bool operator==(const Job &other) const { return isEqual(other); }
inline Job &operator=(const Job &other) { copy(other); return *this; }
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
# ifdef XMRIG_FEATURE_BENCHMARK
inline const String &benchToken() const { return m_benchToken; }
inline uint32_t benchSize() const { return m_benchSize; }
inline uint64_t benchHash() const { return m_benchHash; }
inline void setBenchHash(uint64_t benchHash) { m_benchHash = benchHash; }
inline void setBenchSize(uint32_t size) { m_benchSize = size; }
inline void setBenchToken(const String &token) { m_benchToken = token; }
# endif
private:
void copy(const Job &other);
@ -135,6 +144,12 @@ private:
char m_rawTarget[24]{};
String m_rawSeedHash;
# endif
# ifdef XMRIG_FEATURE_BENCHMARK
String m_benchToken;
uint32_t m_benchSize = 0;
uint64_t m_benchHash = 0;
# endif
};

View file

@ -1,62 +0,0 @@
/* 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());
}

View file

@ -51,7 +51,8 @@
#ifdef XMRIG_FEATURE_BENCHMARK
# include "base/net/stratum/NullClient.h"
# include "base/net/stratum/benchmark/BenchClient.h"
# include "base/net/stratum/benchmark/BenchConfig.h"
#endif
@ -84,10 +85,6 @@ const char *Pool::kUrl = "url";
const char *Pool::kUser = "user";
const char *Pool::kNicehashHost = "nicehash.com";
#ifdef XMRIG_FEATURE_BENCHMARK
const char *Pool::kBenchmark = "benchmark";
#endif
}
@ -139,14 +136,6 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
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;
}
@ -156,6 +145,31 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
}
#ifdef XMRIG_FEATURE_BENCHMARK
xmrig::Pool::Pool(const std::shared_ptr<BenchConfig> &benchmark) :
m_mode(MODE_BENCHMARK),
m_flags(1 << FLAG_ENABLED),
m_url(BenchConfig::kBenchmark),
m_benchmark(benchmark)
{
}
xmrig::BenchConfig *xmrig::Pool::benchmark() const
{
assert(m_mode == MODE_BENCHMARK && m_benchmark);
return m_benchmark.get();
}
uint32_t xmrig::Pool::benchSize() const
{
return benchmark()->size();
}
#endif
bool xmrig::Pool::isEnabled() const
{
# ifndef XMRIG_FEATURE_TLS
@ -233,7 +247,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
# endif
# ifdef XMRIG_FEATURE_BENCHMARK
else if (m_mode == MODE_BENCHMARK) {
client = new NullClient(listener);
client = new BenchClient(m_benchmark, listener);
}
# endif
@ -337,23 +351,3 @@ void xmrig::Pool::setKeepAlive(const rapidjson::Value &value)
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

View file

@ -29,6 +29,7 @@
#include <bitset>
#include <vector>
#include <memory>
#include "3rdparty/rapidjson/fwd.h"
@ -39,6 +40,7 @@
namespace xmrig {
class BenchConfig;
class IClient;
class IClientListener;
@ -76,10 +78,6 @@ 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;
@ -89,6 +87,13 @@ public:
Pool(const char *url);
Pool(const rapidjson::Value &object);
# ifdef XMRIG_FEATURE_BENCHMARK
Pool(const std::shared_ptr<BenchConfig> &benchmark);
BenchConfig *benchmark() const;
uint32_t benchSize() const;
# endif
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
inline bool isTLS() const { return m_flags.test(FLAG_TLS) || m_url.isTLS(); }
inline bool isValid() const { return m_url.isValid(); }
@ -112,10 +117,6 @@ 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); }
@ -157,9 +158,7 @@ private:
Url m_url;
# ifdef XMRIG_FEATURE_BENCHMARK
bool setBenchSize(const char *benchmark);
uint32_t m_benchSize = 0;
std::shared_ptr<BenchConfig> m_benchmark;
# endif
};

View file

@ -32,6 +32,11 @@
#include "donate.h"
#ifdef XMRIG_FEATURE_BENCHMARK
# include "base/net/stratum/benchmark/BenchConfig.h"
#endif
namespace xmrig {
@ -118,6 +123,15 @@ void xmrig::Pools::load(const IJsonReader &reader)
{
m_data.clear();
# ifdef XMRIG_FEATURE_BENCHMARK
m_benchmark = std::shared_ptr<BenchConfig>(BenchConfig::create(reader.getObject(BenchConfig::kBenchmark)));
if (m_benchmark) {
m_data.emplace_back(m_benchmark);
return;
}
# endif
const rapidjson::Value &pools = reader.getArray(kPools);
if (!pools.IsArray()) {
return;
@ -147,12 +161,10 @@ 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 m_benchmark ? m_benchmark->size() : 0;
# else
return 0;
# endif
}

View file

@ -85,6 +85,10 @@ private:
int m_retryPause = 5;
ProxyDonate m_proxyDonate = PROXY_DONATE_AUTO;
std::vector<Pool> m_data;
# ifdef XMRIG_FEATURE_BENCHMARK
std::shared_ptr<BenchConfig> m_benchmark;
# endif
};

View file

@ -0,0 +1,180 @@
/* XMRig
* 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/net/stratum/benchmark/BenchClient.h"
#include "3rdparty/fmt/core.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/cpu/Cpu.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/interfaces/IClientListener.h"
#include "base/net/http/Fetch.h"
#include "base/net/http/HttpData.h"
#include "base/net/http/HttpListener.h"
#include "base/net/stratum/benchmark/BenchConfig.h"
#include "version.h"
xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener) :
m_listener(listener),
m_benchmark(benchmark)
{
m_httpListener = std::make_shared<HttpListener>(this, Tags::bench());
std::vector<char> blob(112 * 2 + 1, '0');
blob.back() = '\0';
m_job.setBlob(blob.data());
m_job.setAlgorithm(m_benchmark->algorithm());
m_job.setDiff(std::numeric_limits<uint64_t>::max());
m_job.setHeight(1);
m_job.setBenchSize(m_benchmark->size());
m_job.setBenchHash(m_benchmark->hash());
if (m_benchmark->isSubmit()) {
m_mode = ONLINE_BENCH;
return;
}
if (!m_benchmark->id().isEmpty()) {
m_job.setId(m_benchmark->id());
m_mode = ONLINE_VERIFY;
return;
}
m_job.setId("00000000");
if (m_job.benchHash() && m_job.setSeedHash(m_benchmark->seed())) {
m_mode = STATIC_VERIFY;
return;
}
blob[Job::kMaxSeedSize * 2] = '\0';
m_job.setSeedHash(blob.data());
}
void xmrig::BenchClient::connect()
{
switch (m_mode) {
case STATIC_BENCH:
case STATIC_VERIFY:
return start();
case ONLINE_BENCH:
return createBench();
case ONLINE_VERIFY:
return getBench();
}
}
void xmrig::BenchClient::setPool(const Pool &pool)
{
m_pool = pool;
}
void xmrig::BenchClient::onHttpData(const HttpData &data)
{
rapidjson::Document doc;
try {
doc = data.json();
} catch (const std::exception &ex) {
return setError(ex.what());
}
if (data.status != 200) {
return setError(data.statusName());
}
if (m_mode == ONLINE_BENCH) {
startBench(doc);
}
else {
startVerify(doc);
}
}
void xmrig::BenchClient::createBench()
{
using namespace rapidjson;
Document doc(kObjectType);
auto &allocator = doc.GetAllocator();
doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator);
doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator);
doc.AddMember("version", APP_VERSION, allocator);
doc.AddMember("cpu", Cpu::toJSON(doc), allocator);
FetchRequest req(HTTP_POST, BenchConfig::kApiHost, BenchConfig::kApiPort, "/1/benchmark", doc, BenchConfig::kApiTLS, true);
fetch(std::move(req), m_httpListener);
}
void xmrig::BenchClient::getBench()
{
FetchRequest req(HTTP_GET, BenchConfig::kApiHost, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_job.id()).c_str(), BenchConfig::kApiTLS, true);
fetch(std::move(req), m_httpListener);
}
void xmrig::BenchClient::setError(const char *message)
{
LOG_ERR("%s " RED("benchmark failed ") RED_BOLD("\"%s\""), Tags::bench(), message);
}
void xmrig::BenchClient::start()
{
m_listener->onLoginSuccess(this);
m_listener->onJobReceived(this, m_job, rapidjson::Value());
}
void xmrig::BenchClient::startBench(const rapidjson::Value &value)
{
m_job.setId(Json::getString(value, BenchConfig::kId));
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
m_job.setBenchToken(Json::getString(value, BenchConfig::kToken));
start();
}
void xmrig::BenchClient::startVerify(const rapidjson::Value &value)
{
const char *hash = Json::getString(value, BenchConfig::kHash);
if (hash) {
m_job.setBenchHash(strtoull(hash, nullptr, 16));
}
m_job.setAlgorithm(Json::getString(value, BenchConfig::kAlgo));
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
m_job.setBenchSize(Json::getUint(value, BenchConfig::kSize));
start();
}

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* 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
@ -16,26 +16,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_NULLCLIENT_H
#define XMRIG_NULLCLIENT_H
#ifndef XMRIG_BENCHCLIENT_H
#define XMRIG_BENCHCLIENT_H
#include "base/net/stratum/Client.h"
#include "base/kernel/interfaces/IHttpListener.h"
namespace xmrig {
class NullClient : public IClient
class BenchClient : public IClient, public IHttpListener
{
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(NullClient)
XMRIG_DISABLE_COPY_MOVE_DEFAULT(BenchClient)
NullClient(IClientListener* listener);
~NullClient() override = default;
BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener);
~BenchClient() override = default;
inline bool disconnect() override { return true; }
inline bool hasExtension(Extension extension) const noexcept override { return false; }
inline bool hasExtension(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"; }
@ -46,32 +47,52 @@ public:
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 send(const rapidjson::Value &, Callback) override { return 0; }
inline int64_t send(const rapidjson::Value &) 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 int64_t submit(const JobResult &) 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 setAlgo(const Algorithm &algo) override {}
inline void setEnabled(bool enabled) override {}
inline void setProxy(const ProxyUrl& proxy) 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;
void setPool(const Pool &pool) override;
protected:
void onHttpData(const HttpData &data) override;
private:
enum Mode : uint32_t {
STATIC_BENCH,
ONLINE_BENCH,
STATIC_VERIFY,
ONLINE_VERIFY
};
void createBench();
void getBench();
void setError(const char *message);
void start();
void startBench(const rapidjson::Value &value);
void startVerify(const rapidjson::Value &value);
IClientListener* m_listener;
Job m_job;
Pool m_pool;
std::shared_ptr<BenchConfig> m_benchmark;
std::shared_ptr<IHttpListener> m_httpListener;
String m_ip;
Mode m_mode = STATIC_BENCH;
};
} /* namespace xmrig */
#endif /* XMRIG_NULLCLIENT_H */
#endif /* XMRIG_BENCHCLIENT_H */

View file

@ -0,0 +1,103 @@
/* XMRig
* 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/net/stratum/benchmark/BenchConfig.h"
#include "3rdparty/fmt/core.h"
#include "3rdparty/rapidjson/document.h"
#include "base/io/json/Json.h"
#include <string>
#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif
namespace xmrig {
const char *BenchConfig::kAlgo = "algo";
const char *BenchConfig::kBenchmark = "benchmark";
const char *BenchConfig::kHash = "hash";
const char *BenchConfig::kId = "id";
const char *BenchConfig::kSeed = "seed";
const char *BenchConfig::kSize = "size";
const char *BenchConfig::kSubmit = "submit";
const char *BenchConfig::kToken = "token";
const char *BenchConfig::kVerify = "verify";
#ifndef XMRIG_DEBUG_BENCHMARK_API
const char *BenchConfig::kApiHost = "api.xmrig.com";
#else
const char *BenchConfig::kApiHost = "127.0.0.1";
#endif
} // namespace xmrig
xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object) :
m_algorithm(Json::getString(object, kAlgo)),
m_submit(Json::getBool(object, kSubmit)),
m_id(id),
m_seed(Json::getString(object, kSeed)),
m_size(size),
m_hash(0)
{
if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) {
m_algorithm = Algorithm::RX_0;
}
const char *hash = Json::getString(object, kHash);
if (hash) {
m_hash = strtoull(hash, nullptr, 16);
}
}
xmrig::BenchConfig *xmrig::BenchConfig::create(const rapidjson::Value &object)
{
if (!object.IsObject() || object.ObjectEmpty()) {
return nullptr;
}
const uint32_t size = getSize(Json::getString(object, kSize));
const String id = Json::getString(object, kVerify);
if (size == 0 && id.isEmpty()) {
return nullptr;
}
return new BenchConfig(size, id, object);
}
uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
{
if (!benchmark) {
return false;
}
const auto size = strtoul(benchmark, nullptr, 10);
if (size < 1 || size > 10) {
return false;
}
return strcasecmp(benchmark, fmt::format("{}M", size).c_str()) == 0 ? size * 1000000 : 0;
}

View file

@ -0,0 +1,78 @@
/* XMRig
* 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_BENCHCONFIG_H
#define XMRIG_BENCHCONFIG_H
#include "base/crypto/Algorithm.h"
#include "base/tools/String.h"
namespace xmrig {
class BenchConfig
{
public:
static const char *kAlgo;
static const char *kApiHost;
static const char *kBenchmark;
static const char *kHash;
static const char *kId;
static const char *kSeed;
static const char *kSize;
static const char *kSubmit;
static const char *kToken;
static const char *kVerify;
# ifndef XMRIG_DEBUG_BENCHMARK_API
static constexpr bool kApiTLS = true;
static constexpr const uint16_t kApiPort = 443;
# else
static constexpr bool kApiTLS = false;
static constexpr const uint16_t kApiPort = 18805;
# endif
BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object);
static BenchConfig *create(const rapidjson::Value &object);
inline bool isSubmit() const { return m_submit; }
inline const Algorithm &algorithm() const { return m_algorithm; }
inline const String &id() const { return m_id; }
inline const String &seed() const { return m_seed; }
inline uint32_t size() const { return m_size; }
inline uint64_t hash() const { return m_hash; }
private:
static uint32_t getSize(const char *benchmark);
Algorithm m_algorithm;
bool m_submit;
String m_id;
String m_seed;
uint32_t m_size;
uint64_t m_hash;
};
} /* namespace xmrig */
#endif /* XMRIG_BENCHCONFIG_H */

View file

@ -1,12 +1,6 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* 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
@ -34,9 +28,7 @@ xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &pools, int re
m_quiet(quiet),
m_retries(retries),
m_retryPause(retryPause),
m_active(-1),
m_listener(listener),
m_index(0)
m_listener(listener)
{
for (const Pool &pool : pools) {
add(pool);
@ -48,9 +40,7 @@ xmrig::FailoverStrategy::FailoverStrategy(int retryPause, int retries, IStrategy
m_quiet(quiet),
m_retries(retries),
m_retryPause(retryPause),
m_active(-1),
m_listener(listener),
m_index(0)
m_listener(listener)
{
}

View file

@ -1,12 +1,6 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* 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
@ -78,9 +72,9 @@ private:
const bool m_quiet;
const int m_retries;
const int m_retryPause;
int m_active;
int m_active = -1;
IStrategyListener *m_listener;
size_t m_index;
size_t m_index = 0;
std::vector<IClient*> m_pools;
};