Sync changes with proxy.

This commit is contained in:
XMRig 2018-04-25 14:48:32 +07:00
parent b9fec2fcc4
commit ca149d2eed
22 changed files with 436 additions and 328 deletions

View file

@ -19,6 +19,7 @@ set(HEADERS
src/common/config/ConfigLoader.h src/common/config/ConfigLoader.h
src/common/config/ConfigWatcher.h src/common/config/ConfigWatcher.h
src/common/Console.h src/common/Console.h
src/common/crypto/Algorithm.h
src/common/crypto/keccak.h src/common/crypto/keccak.h
src/common/log/ConsoleLog.h src/common/log/ConsoleLog.h
src/common/log/FileLog.h src/common/log/FileLog.h
@ -93,6 +94,7 @@ set(SOURCES
src/common/config/ConfigLoader.cpp src/common/config/ConfigLoader.cpp
src/common/config/ConfigWatcher.cpp src/common/config/ConfigWatcher.cpp
src/common/Console.cpp src/common/Console.cpp
src/common/crypto/Algorithm.cpp
src/common/crypto/keccak.cpp src/common/crypto/keccak.cpp
src/common/log/ConsoleLog.cpp src/common/log/ConsoleLog.cpp
src/common/log/FileLog.cpp src/common/log/FileLog.cpp

View file

@ -104,7 +104,7 @@ static void print_threads(xmrig::Config *config)
Log::i()->text(config->isColors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, %sdonate=%d%%%s" : " * THREADS: %d, %s, av=%d, %sdonate=%d%%%s", Log::i()->text(config->isColors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, %sdonate=%d%%%s" : " * THREADS: %d, %s, av=%d, %sdonate=%d%%%s",
config->threadsCount(), config->threadsCount(),
config->algoName(), config->algorithm().name(),
config->algoVariant(), config->algoVariant(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[01;31m" : "", config->isColors() && config->donateLevel() == 0 ? "\x1B[01;31m" : "",
config->donateLevel(), config->donateLevel(),
@ -113,7 +113,7 @@ static void print_threads(xmrig::Config *config)
else { else {
Log::i()->text(config->isColors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, %sdonate=%d%%" : " * THREADS: %d, %s, %sdonate=%d%%", Log::i()->text(config->isColors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, %sdonate=%d%%" : " * THREADS: %d, %s, %sdonate=%d%%",
config->threadsCount(), config->threadsCount(),
config->algoName(), config->algorithm().name(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[01;31m" : "", config->isColors() && config->donateLevel() == 0 ? "\x1B[01;31m" : "",
config->donateLevel()); config->donateLevel());
} }

View file

@ -244,7 +244,7 @@ void ApiRouter::getMiner(rapidjson::Document &doc) const
doc.AddMember("kind", APP_KIND, allocator); doc.AddMember("kind", APP_KIND, allocator);
doc.AddMember("ua", rapidjson::StringRef(Platform::userAgent()), allocator); doc.AddMember("ua", rapidjson::StringRef(Platform::userAgent()), allocator);
doc.AddMember("cpu", cpu, allocator); doc.AddMember("cpu", cpu, allocator);
doc.AddMember("algo", rapidjson::StringRef(m_controller->config()->algoName()), allocator); doc.AddMember("algo", rapidjson::StringRef(m_controller->config()->algorithm().name()), allocator);
doc.AddMember("hugepages", Workers::hugePages() > 0, allocator); doc.AddMember("hugepages", Workers::hugePages() > 0, allocator);
doc.AddMember("donate_level", m_controller->config()->donateLevel(), allocator); doc.AddMember("donate_level", m_controller->config()->donateLevel(), allocator);
} }

View file

@ -38,7 +38,6 @@
xmrig::CommonConfig::CommonConfig() : xmrig::CommonConfig::CommonConfig() :
m_algorithm(CRYPTONIGHT),
m_adjusted(false), m_adjusted(false),
m_apiIPv6(false), m_apiIPv6(false),
m_apiRestricted(true), m_apiRestricted(true),
@ -80,8 +79,12 @@ bool xmrig::CommonConfig::adjust()
m_adjusted = true; m_adjusted = true;
if (!m_algorithm.isValid()) {
m_algorithm.setAlgo(CRYPTONIGHT);
}
for (Pool &pool : m_pools) { for (Pool &pool : m_pools) {
pool.adjust(algorithm()); pool.adjust(m_algorithm.algo());
} }
return true; return true;
@ -90,7 +93,7 @@ bool xmrig::CommonConfig::adjust()
bool xmrig::CommonConfig::isValid() const bool xmrig::CommonConfig::isValid() const
{ {
return m_pools[0].isValid() && m_algorithm != INVALID_ALGO; return m_pools[0].isValid() && m_algorithm.isValid();
} }
@ -141,7 +144,7 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
{ {
switch (key) { switch (key) {
case AlgorithmKey: /* --algo */ case AlgorithmKey: /* --algo */
m_algorithm = Pool::algorithm(arg); m_algorithm.parseAlgorithm(arg);
break; break;
case UserpassKey: /* --userpass */ case UserpassKey: /* --userpass */
@ -181,6 +184,10 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
m_pools.back().setRigId(arg); m_pools.back().setRigId(arg);
break; break;
case VariantKey: /* --variant */
m_pools.back().algorithm().parseVariant(arg);
break;
case LogFileKey: /* --log-file */ case LogFileKey: /* --log-file */
m_logFile = arg; m_logFile = arg;
break; break;
@ -199,7 +206,6 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
case RetriesKey: /* --retries */ case RetriesKey: /* --retries */
case RetryPauseKey: /* --retry-pause */ case RetryPauseKey: /* --retry-pause */
case VariantKey: /* --variant */
case ApiPort: /* --api-port */ case ApiPort: /* --api-port */
case PrintTimeKey: /* --cpu-priority */ case PrintTimeKey: /* --cpu-priority */
return parseUint64(key, strtol(arg, nullptr, 10)); return parseUint64(key, strtol(arg, nullptr, 10));
@ -299,7 +305,7 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
break; break;
case VariantKey: /* --variant */ case VariantKey: /* --variant */
m_pools.back().setVariant(arg); m_pools.back().algorithm().parseVariant(arg);
break; break;
case DonateLevelKey: /* --donate-level */ case DonateLevelKey: /* --donate-level */

View file

@ -43,13 +43,12 @@ public:
CommonConfig(); CommonConfig();
~CommonConfig(); ~CommonConfig();
inline Algo algorithm() const { return m_algorithm; }
inline bool isApiIPv6() const { return m_apiIPv6; } inline bool isApiIPv6() const { return m_apiIPv6; }
inline bool isApiRestricted() const { return m_apiRestricted; } inline bool isApiRestricted() const { return m_apiRestricted; }
inline bool isBackground() const { return m_background; } inline bool isBackground() const { return m_background; }
inline bool isColors() const { return m_colors; } inline bool isColors() const { return m_colors; }
inline bool isSyslog() const { return m_syslog; } inline bool isSyslog() const { return m_syslog; }
inline const char *algoName() const { return Pool::algoName(m_algorithm); } inline const Algorithm &algorithm() const { return m_algorithm; }
inline const char *apiToken() const { return m_apiToken.data(); } inline const char *apiToken() const { return m_apiToken.data(); }
inline const char *apiWorkerId() const { return m_apiWorkerId.data(); } inline const char *apiWorkerId() const { return m_apiWorkerId.data(); }
inline const char *logFile() const { return m_logFile.data(); } inline const char *logFile() const { return m_logFile.data(); }
@ -74,7 +73,7 @@ protected:
bool save() override; bool save() override;
void setFileName(const char *fileName) override; void setFileName(const char *fileName) override;
Algo m_algorithm; Algorithm m_algorithm;
bool m_adjusted; bool m_adjusted;
bool m_apiIPv6; bool m_apiIPv6;
bool m_apiRestricted; bool m_apiRestricted;

View file

@ -0,0 +1,158 @@
/* 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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2016-2018 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 <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "common/crypto/Algorithm.h"
#ifdef _MSC_VER
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
#endif
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
struct AlgoData
{
const char *name;
const char *shortName;
xmrig::Algo algo;
xmrig::Variant variant;
};
static AlgoData const algorithms[] = {
{ "cryptonight", "cn", xmrig::CRYPTONIGHT, xmrig::VARIANT_AUTO },
{ "cryptonight/0", "cn/0", xmrig::CRYPTONIGHT, xmrig::VARIANT_0 },
{ "cryptonight/1", "cn/1", xmrig::CRYPTONIGHT, xmrig::VARIANT_1 },
{ "cryptonight/xtl", "cn/xtl", xmrig::CRYPTONIGHT, xmrig::VARIANT_XTL },
# ifndef XMRIG_NO_AEON
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
{ "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 },
{ "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 },
{ "cryptonight-lite/ipbc", "cn-lite/ipbc", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_IBPC },
# endif
# ifndef XMRIG_NO_SUMO
{ "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
# endif
};
static const char *variants[] = {
"0",
"1",
"ipbc",
"xtl"
};
const char *xmrig::Algorithm::variantName() const
{
if (m_variant == VARIANT_AUTO) {
return "auto";
}
return variants[m_variant];
}
void xmrig::Algorithm::parseAlgorithm(const char *algo)
{
m_algo = INVALID_ALGO;
m_variant = VARIANT_AUTO;
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) {
m_algo = algorithms[i].algo;
m_variant = algorithms[i].variant;
break;
}
}
if (m_algo == INVALID_ALGO) {
assert(false);
}
}
void xmrig::Algorithm::parseVariant(const char *variant)
{
if (m_algo == CRYPTONIGHT_HEAVY) {
return;
}
m_variant = VARIANT_AUTO;
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
if (strcasecmp(variant, variants[i]) == 0) {
m_variant = static_cast<Variant>(i);
break;
}
}
}
void xmrig::Algorithm::parseVariant(int variant)
{
if (variant >= VARIANT_AUTO && variant <= VARIANT_XTL) {
m_variant = static_cast<Variant>(variant);
}
else {
assert(false);
}
}
void xmrig::Algorithm::setAlgo(Algo algo)
{
m_algo = algo;
if (m_algo == CRYPTONIGHT_HEAVY) {
m_variant = VARIANT_0;
}
}
const char *xmrig::Algorithm::name(bool shortName) const
{
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
if (algorithms[i].algo == m_algo && algorithms[i].variant == m_variant) {
return shortName ? algorithms[i].shortName : algorithms[i].name;
}
}
return "invalid";
}

View file

@ -0,0 +1,76 @@
/* 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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2016-2018 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 __ALGORITHM_H__
#define __ALGORITHM_H__
#include "common/xmrig.h"
namespace xmrig {
class Algorithm
{
public:
inline Algorithm() :
m_algo(INVALID_ALGO),
m_variant(VARIANT_AUTO)
{}
inline Algorithm(Algo algo, Variant variant) :
m_variant(variant)
{
setAlgo(algo);
}
bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
inline Algo algo() const { return m_algo; }
inline bool isValid() const { return m_algo != INVALID_ALGO; }
inline const char *name() const { return name(false); }
inline const char *shortName() const { return name(true); }
inline Variant variant() const { return m_variant; }
inline void setVariant(Variant variant) { m_variant = variant; }
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
const char *variantName() const;
void parseAlgorithm(const char *algo);
void parseVariant(const char *variant);
void parseVariant(int variant);
void setAlgo(Algo algo);
private:
const char *name(bool shortName) const;
Algo m_algo;
Variant m_variant;
};
} /* namespace xmrig */
#endif /* __ALGORITHM_H__ */

View file

@ -232,7 +232,7 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
return false; return false;
} }
Job job(m_id, m_nicehash, m_pool.algorithm(), m_pool.variant(), m_rpcId); Job job(m_id, m_nicehash, m_pool.algorithm(), m_rpcId);
if (!job.setId(params["job_id"].GetString())) { if (!job.setId(params["job_id"].GetString())) {
*code = 3; *code = 3;
@ -250,7 +250,7 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
} }
if (params.HasMember("variant")) { if (params.HasMember("variant")) {
job.setVariant(params["variant"].GetInt()); job.algorithm().parseVariant(params["variant"].GetInt());
} }
if (m_job != job) { if (m_job != job) {

View file

@ -64,14 +64,12 @@ Job::Job() :
m_size(0), m_size(0),
m_diff(0), m_diff(0),
m_target(0), m_target(0),
m_blob(), m_blob()
m_algorithm(xmrig::INVALID_ALGO),
m_variant(xmrig::VARIANT_AUTO)
{ {
} }
Job::Job(int poolId, bool nicehash, xmrig::Algo algo, xmrig::Variant variant, const xmrig::Id &clientId) : Job::Job(int poolId, bool nicehash, xmrig::Algorithm algorithm, const xmrig::Id &clientId) :
m_nicehash(nicehash), m_nicehash(nicehash),
m_poolId(poolId), m_poolId(poolId),
m_threadId(-1), m_threadId(-1),
@ -79,9 +77,8 @@ Job::Job(int poolId, bool nicehash, xmrig::Algo algo, xmrig::Variant variant, co
m_diff(0), m_diff(0),
m_target(0), m_target(0),
m_blob(), m_blob(),
m_algorithm(algo), m_algorithm(algorithm),
m_clientId(clientId), m_clientId(clientId)
m_variant(variant)
{ {
} }
@ -166,23 +163,6 @@ bool Job::setTarget(const char *target)
} }
void Job::setVariant(int variant)
{
switch (variant) {
case xmrig::VARIANT_AUTO:
case xmrig::VARIANT_V0:
case xmrig::VARIANT_V1:
m_variant = static_cast<xmrig::Variant>(variant);
break;
default:
assert(false);
m_variant = xmrig::VARIANT_AUTO;
break;
}
}
bool Job::fromHex(const char* in, unsigned int len, unsigned char* out) bool Job::fromHex(const char* in, unsigned int len, unsigned char* out)
{ {
bool error = false; bool error = false;

View file

@ -30,26 +30,26 @@
#include <stdint.h> #include <stdint.h>
#include "common/crypto/Algorithm.h"
#include "common/net/Id.h" #include "common/net/Id.h"
#include "common/xmrig.h"
class Job class Job
{ {
public: public:
Job(); Job();
Job(int poolId, bool nicehash, xmrig::Algo algo, xmrig::Variant variant, const xmrig::Id &clientId); Job(int poolId, bool nicehash, xmrig::Algorithm algorithm, const xmrig::Id &clientId);
~Job(); ~Job();
bool setBlob(const char *blob); bool setBlob(const char *blob);
bool setTarget(const char *target); bool setTarget(const char *target);
void setVariant(int variant);
inline bool isNicehash() const { return m_nicehash; } inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return m_size > 0 && m_diff > 0; } inline bool isValid() const { return m_size > 0 && m_diff > 0; }
inline bool setId(const char *id) { return m_id.setId(id); } inline bool setId(const char *id) { return m_id.setId(id); }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); } inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); }
inline const uint8_t *blob() const { return m_blob; } inline const uint8_t *blob() const { return m_blob; }
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
inline const xmrig::Id &clientId() const { return m_clientId; } inline const xmrig::Id &clientId() const { return m_clientId; }
inline const xmrig::Id &id() const { return m_id; } inline const xmrig::Id &id() const { return m_id; }
inline int poolId() const { return m_poolId; } inline int poolId() const { return m_poolId; }
@ -62,8 +62,12 @@ public:
inline void setClientId(const xmrig::Id &id) { m_clientId = id; } inline void setClientId(const xmrig::Id &id) { m_clientId = id; }
inline void setPoolId(int poolId) { m_poolId = poolId; } inline void setPoolId(int poolId) { m_poolId = poolId; }
inline void setThreadId(int threadId) { m_threadId = threadId; } inline void setThreadId(int threadId) { m_threadId = threadId; }
inline xmrig::Algo algorithm() const { return m_algorithm; } inline xmrig::Algorithm &algorithm() { return m_algorithm; }
inline xmrig::Variant variant() const { return (m_variant == xmrig::VARIANT_AUTO ? (m_blob[0] > 6 ? xmrig::VARIANT_V1 : xmrig::VARIANT_V0) : m_variant); }
inline xmrig::Variant variant() const
{
return (m_algorithm.variant() == xmrig::VARIANT_AUTO ? (m_blob[0] > 6 ? xmrig::VARIANT_1 : xmrig::VARIANT_0) : m_algorithm.variant());
}
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
inline char *rawBlob() { return m_rawBlob; } inline char *rawBlob() { return m_rawBlob; }
@ -90,10 +94,9 @@ private:
uint64_t m_diff; uint64_t m_diff;
uint64_t m_target; uint64_t m_target;
uint8_t m_blob[96]; // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk. uint8_t m_blob[96]; // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
xmrig::Algo m_algorithm; xmrig::Algorithm m_algorithm;
xmrig::Id m_clientId; xmrig::Id m_clientId;
xmrig::Id m_id; xmrig::Id m_id;
xmrig::Variant m_variant;
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
char m_rawBlob[176]; char m_rawBlob[176];

View file

@ -29,6 +29,7 @@
#include "common/net/Pool.h" #include "common/net/Pool.h"
#include "rapidjson/document.h"
#ifdef APP_DEBUG #ifdef APP_DEBUG
@ -42,52 +43,10 @@
#endif #endif
static const char *algoNames[] = {
"cryptonight",
# ifndef XMRIG_NO_AEON
"cryptonight-lite",
# else
nullptr,
# endif
# ifndef XMRIG_NO_SUMO
"cryptonight-heavy",
# else
nullptr,
# endif
# ifndef XMRIG_NO_IPBC
"cryptonight-ipbc",
# else
nullptr,
# endif
};
static const char *algoNamesShort[] = {
"cn",
# ifndef XMRIG_NO_AEON
"cn-lite",
# else
nullptr,
# endif
# ifndef XMRIG_NO_SUMO
"cn-heavy",
# else
nullptr,
# endif
# ifndef XMRIG_NO_IPBC
"cn-ipbc",
# else
nullptr,
# endif
};
Pool::Pool() : Pool::Pool() :
m_nicehash(false), m_nicehash(false),
m_keepAlive(0), m_keepAlive(0),
m_port(kDefaultPort), m_port(kDefaultPort)
m_algorithm(xmrig::INVALID_ALGO),
m_variant(xmrig::VARIANT_AUTO)
{ {
} }
@ -106,23 +65,19 @@ Pool::Pool() :
Pool::Pool(const char *url) : Pool::Pool(const char *url) :
m_nicehash(false), m_nicehash(false),
m_keepAlive(0), m_keepAlive(0),
m_port(kDefaultPort), m_port(kDefaultPort)
m_algorithm(xmrig::INVALID_ALGO),
m_variant(xmrig::VARIANT_AUTO)
{ {
parse(url); parse(url);
} }
Pool::Pool(const char *host, uint16_t port, const char *user, const char *password, int keepAlive, bool nicehash, xmrig::Variant variant) : Pool::Pool(const char *host, uint16_t port, const char *user, const char *password, int keepAlive, bool nicehash) :
m_nicehash(nicehash), m_nicehash(nicehash),
m_keepAlive(keepAlive), m_keepAlive(keepAlive),
m_port(port), m_port(port),
m_algorithm(xmrig::INVALID_ALGO),
m_host(host), m_host(host),
m_password(password), m_password(password),
m_user(user), m_user(user)
m_variant(variant)
{ {
const size_t size = m_host.size() + 8; const size_t size = m_host.size() + 8;
assert(size > 8); assert(size > 8);
@ -134,41 +89,6 @@ Pool::Pool(const char *host, uint16_t port, const char *user, const char *passwo
} }
const char *Pool::algoName(xmrig::Algo algorithm, bool shortName)
{
if (algorithm == xmrig::INVALID_ALGO) {
return "invalid";
}
return (shortName ? algoNamesShort : algoNames)[algorithm];
}
xmrig::Algo Pool::algorithm(const char *algo)
{
# ifndef XMRIG_NO_AEON
if (strcasecmp(algo, "cryptonight-light") == 0) {
fprintf(stderr, "Algorithm \"cryptonight-light\" is deprecated, use \"cryptonight-lite\" instead\n");
return xmrig::CRYPTONIGHT_LITE;
}
# endif
const size_t size = sizeof(algoNames) / sizeof(algoNames[0]);
assert(size == (sizeof(algoNamesShort) / sizeof(algoNamesShort[0])));
for (size_t i = 0; i < size; i++) {
if ((algoNames[i] && strcasecmp(algo, algoNames[i]) == 0) || (algoNamesShort[i] && strcasecmp(algo, algoNamesShort[i]) == 0)) {
return static_cast<xmrig::Algo>(i);
}
}
fprintf(stderr, "Unknown algorithm \"%s\" specified.\n", algo);
return xmrig::INVALID_ALGO;
}
bool Pool::isEqual(const Pool &other) const bool Pool::isEqual(const Pool &other) const
{ {
return (m_nicehash == other.m_nicehash return (m_nicehash == other.m_nicehash
@ -179,8 +99,7 @@ bool Pool::isEqual(const Pool &other) const
&& m_password == other.m_password && m_password == other.m_password
&& m_rigId == other.m_rigId && m_rigId == other.m_rigId
&& m_url == other.m_url && m_url == other.m_url
&& m_user == other.m_user && m_user == other.m_user);
&& m_variant == other.m_variant);
} }
@ -242,14 +161,54 @@ bool Pool::setUserpass(const char *userpass)
} }
rapidjson::Value Pool::toJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;
auto &allocator = doc.GetAllocator();
Value obj(kObjectType);
obj.AddMember("url", StringRef(url()), allocator);
obj.AddMember("user", StringRef(user()), allocator);
obj.AddMember("pass", StringRef(password()), allocator);
obj.AddMember("rig-id", rigId() ? Value(StringRef(rigId())).Move() : Value(kNullType).Move(), allocator);
# ifndef XMRIG_PROXY_PROJECT
obj.AddMember("nicehash", isNicehash(), allocator);
# endif
if (m_keepAlive == 0 || m_keepAlive == kKeepAliveTimeout) {
obj.AddMember("keepalive", m_keepAlive > 0, allocator);
}
else {
obj.AddMember("keepalive", m_keepAlive, allocator);
}
switch (m_algorithm.variant()) {
case xmrig::VARIANT_AUTO:
case xmrig::VARIANT_0:
case xmrig::VARIANT_1:
obj.AddMember("variant", m_algorithm.variant(), allocator);
break;
default:
obj.AddMember("variant", StringRef(m_algorithm.variantName()), allocator);
break;
}
return obj;
}
void Pool::adjust(xmrig::Algo algorithm) void Pool::adjust(xmrig::Algo algorithm)
{ {
if (!isValid()) { if (!isValid()) {
return; return;
} }
if (m_algorithm == xmrig::INVALID_ALGO) { if (!m_algorithm.isValid()) {
m_algorithm = algorithm; m_algorithm.setAlgo(algorithm);
} }
if (strstr(m_host.data(), ".nicehash.com")) { if (strstr(m_host.data(), ".nicehash.com")) {
@ -257,50 +216,17 @@ void Pool::adjust(xmrig::Algo algorithm)
m_nicehash = true; m_nicehash = true;
if (strstr(m_host.data(), "cryptonightv7.")) { if (strstr(m_host.data(), "cryptonightv7.")) {
m_variant = xmrig::VARIANT_V1; m_algorithm.setVariant(xmrig::VARIANT_1);
} }
} }
if (strstr(m_host.data(), ".minergate.com")) { if (strstr(m_host.data(), ".minergate.com")) {
m_variant = xmrig::VARIANT_V1;
m_keepAlive = false; m_keepAlive = false;
m_algorithm.setVariant(xmrig::VARIANT_1);
} }
} }
void Pool::setVariant(int variant)
{
switch (variant) {
case xmrig::VARIANT_AUTO:
case xmrig::VARIANT_V0:
case xmrig::VARIANT_V1:
m_variant = static_cast<xmrig::Variant>(variant);
break;
default:
assert(false);
break;
}
}
xmrig::Variant Pool::variant() const
{
switch (m_algorithm) {
case xmrig::CRYPTONIGHT_HEAVY:
return xmrig::VARIANT_V0;
case xmrig::CRYPTONIGHT_IPBC:
return xmrig::VARIANT_V1;
default:
break;
}
return m_variant;
}
#ifdef APP_DEBUG #ifdef APP_DEBUG
void Pool::print() const void Pool::print() const
{ {
@ -309,8 +235,8 @@ void Pool::print() const
LOG_DEBUG ("port: %d", static_cast<int>(m_port)); LOG_DEBUG ("port: %d", static_cast<int>(m_port));
LOG_DEBUG ("user: %s", m_user.data()); LOG_DEBUG ("user: %s", m_user.data());
LOG_DEBUG ("pass: %s", m_password.data()); LOG_DEBUG ("pass: %s", m_password.data());
LOG_DEBUG ("rig_id %s", m_rigId.data()); LOG_DEBUG ("rig-id %s", m_rigId.data());
LOG_DEBUG ("algo: %s/%d", algoName(m_algorithm), static_cast<int>(variant())); LOG_DEBUG ("algo: %s", m_algorithm.name());
LOG_DEBUG ("nicehash: %d", static_cast<int>(m_nicehash)); LOG_DEBUG ("nicehash: %d", static_cast<int>(m_nicehash));
LOG_DEBUG ("keepAlive: %d", m_keepAlive); LOG_DEBUG ("keepAlive: %d", m_keepAlive);
} }

View file

@ -28,8 +28,9 @@
#include <stdint.h> #include <stdint.h>
#include "common/crypto/Algorithm.h"
#include "common/utils/c_str.h" #include "common/utils/c_str.h"
#include "common/xmrig.h" #include "rapidjson/fwd.h"
class Pool class Pool
@ -47,13 +48,9 @@ public:
const char *user = nullptr, const char *user = nullptr,
const char *password = nullptr, const char *password = nullptr,
int keepAlive = 0, int keepAlive = 0,
bool nicehash = false, bool nicehash = false
xmrig::Variant variant = xmrig::VARIANT_AUTO
); );
static const char *algoName(xmrig::Algo algorithm, bool shortName = false);
static xmrig::Algo algorithm(const char *algo);
inline bool isNicehash() const { return m_nicehash; } inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return !m_host.isNull() && m_port > 0; } inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
inline const char *host() const { return m_host.data(); } inline const char *host() const { return m_host.data(); }
@ -61,16 +58,15 @@ public:
inline const char *rigId() const { return m_rigId.data(); } inline const char *rigId() const { return m_rigId.data(); }
inline const char *url() const { return m_url.data(); } inline const char *url() const { return m_url.data(); }
inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; } inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
inline int keepAlive() const { return m_keepAlive; } inline int keepAlive() const { return m_keepAlive; }
inline uint16_t port() const { return m_port; } inline uint16_t port() const { return m_port; }
inline void setAlgo(const char *algo) { m_algorithm = algorithm(algo); }
inline void setAlgo(xmrig::Algo algorithm) { m_algorithm = algorithm; }
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; } inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
inline void setPassword(const char *password) { m_password = password; } inline void setPassword(const char *password) { m_password = password; }
inline void setRigId(const char *rigId) { m_rigId = rigId; } inline void setRigId(const char *rigId) { m_rigId = rigId; }
inline void setUser(const char *user) { m_user = user; } inline void setUser(const char *user) { m_user = user; }
inline xmrig::Algo algorithm() const { return m_algorithm; } inline xmrig::Algorithm &algorithm() { return m_algorithm; }
inline bool operator!=(const Pool &other) const { return !isEqual(other); } inline bool operator!=(const Pool &other) const { return !isEqual(other); }
inline bool operator==(const Pool &other) const { return isEqual(other); } inline bool operator==(const Pool &other) const { return isEqual(other); }
@ -78,9 +74,8 @@ public:
bool isEqual(const Pool &other) const; bool isEqual(const Pool &other) const;
bool parse(const char *url); bool parse(const char *url);
bool setUserpass(const char *userpass); bool setUserpass(const char *userpass);
rapidjson::Value toJSON(rapidjson::Document &doc) const;
void adjust(xmrig::Algo algorithm); void adjust(xmrig::Algo algorithm);
void setVariant(int variant);
xmrig::Variant variant() const;
# ifdef APP_DEBUG # ifdef APP_DEBUG
void print() const; void print() const;
@ -92,13 +87,12 @@ private:
bool m_nicehash; bool m_nicehash;
int m_keepAlive; int m_keepAlive;
uint16_t m_port; uint16_t m_port;
xmrig::Algo m_algorithm; xmrig::Algorithm m_algorithm;
xmrig::c_str m_host; xmrig::c_str m_host;
xmrig::c_str m_password; xmrig::c_str m_password;
xmrig::c_str m_rigId; xmrig::c_str m_rigId;
xmrig::c_str m_url; xmrig::c_str m_url;
xmrig::c_str m_user; xmrig::c_str m_user;
xmrig::Variant m_variant;
}; };
#endif /* __POOL_H__ */ #endif /* __POOL_H__ */

View file

@ -29,9 +29,6 @@
#include <map> #include <map>
#include "common/log/Log.h"
namespace xmrig { namespace xmrig {

View file

@ -68,7 +68,7 @@ public:
inline bool isEqual(const char *str) const inline bool isEqual(const char *str) const
{ {
return (m_data != nullptr && str != nullptr && strcmp(m_data, str)) || (m_data == nullptr && m_data == nullptr); return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && m_data == nullptr);
} }

View file

@ -33,8 +33,7 @@ enum Algo {
INVALID_ALGO = -1, INVALID_ALGO = -1,
CRYPTONIGHT, /* CryptoNight (Monero) */ CRYPTONIGHT, /* CryptoNight (Monero) */
CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (SUMO) */ CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (SUMO) */
CRYPTONIGHT_IPBC /* CryptoNight-IPBC (IPBC) */
}; };
@ -60,8 +59,10 @@ enum AlgoVariant {
enum Variant { enum Variant {
VARIANT_AUTO = -1, // Autodetect VARIANT_AUTO = -1, // Autodetect
VARIANT_V0 = 0, // Original CryptoNight or CryptoNight-Heavy VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
VARIANT_V1 = 1 // Monero v7 PoW VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7
VARIANT_IBPC = 2, // CryptoNight Lite variant 1 with XOR (IPBC only)
VARIANT_XTL = 3 // CryptoNight variant 1 (Stellite only)
}; };

View file

@ -71,7 +71,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
auto &allocator = doc.GetAllocator(); auto &allocator = doc.GetAllocator();
doc.AddMember("algo", StringRef(algoName()), allocator); doc.AddMember("algo", StringRef(algorithm().name()), allocator);
Value api(kObjectType); Value api(kObjectType);
api.AddMember("port", apiPort(), allocator); api.AddMember("port", apiPort(), allocator);
@ -103,24 +103,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
Value pools(kArrayType); Value pools(kArrayType);
for (const Pool &pool : m_pools) { for (const Pool &pool : m_pools) {
Value obj(kObjectType); pools.PushBack(pool.toJSON(doc), allocator);
obj.AddMember("url", StringRef(pool.url()), allocator);
obj.AddMember("user", StringRef(pool.user()), allocator);
obj.AddMember("pass", StringRef(pool.password()), allocator);
obj.AddMember("rig-id", pool.rigId() ? Value(StringRef(pool.rigId())).Move() : Value(kNullType).Move(), allocator);
if (pool.keepAlive() == 0 || pool.keepAlive() == Pool::kKeepAliveTimeout) {
obj.AddMember("keepalive", pool.keepAlive() > 0, allocator);
}
else {
obj.AddMember("keepalive", pool.keepAlive(), allocator);
}
obj.AddMember("nicehash", pool.isNicehash(), allocator);
obj.AddMember("variant", pool.variant(), allocator);
pools.PushBack(obj, allocator);
} }
doc.AddMember("pools", pools, allocator); doc.AddMember("pools", pools, allocator);
@ -169,7 +152,7 @@ bool xmrig::Config::adjust()
const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT; const bool softAES = (m_aesMode == AES_AUTO ? (Cpu::hasAES() ? AES_HW : AES_SOFT) : m_aesMode) == AES_SOFT;
for (size_t i = 0; i < m_threads.cpu.size(); ++i) { for (size_t i = 0; i < m_threads.cpu.size(); ++i) {
m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm, m_threads.cpu[i], m_priority, softAES)); m_threads.list.push_back(CpuThread::createFromData(i, m_algorithm.algo(), m_threads.cpu[i], m_priority, softAES));
} }
return true; return true;
@ -178,7 +161,7 @@ bool xmrig::Config::adjust()
m_algoVariant = getAlgoVariant(); m_algoVariant = getAlgoVariant();
m_threads.mode = m_threads.count ? Simple : Automatic; m_threads.mode = m_threads.count ? Simple : Automatic;
const size_t size = CpuThread::multiway(m_algoVariant) * cn_select_memory(m_algorithm) / 1024; const size_t size = CpuThread::multiway(m_algoVariant) * cn_select_memory(m_algorithm.algo()) / 1024;
if (!m_threads.count) { if (!m_threads.count) {
m_threads.count = Cpu::optimalThreadsCount(size, m_maxCpuUsage); m_threads.count = Cpu::optimalThreadsCount(size, m_maxCpuUsage);
@ -191,7 +174,7 @@ bool xmrig::Config::adjust()
} }
for (size_t i = 0; i < m_threads.count; ++i) { for (size_t i = 0; i < m_threads.count; ++i) {
m_threads.list.push_back(CpuThread::createFromAV(i, m_algorithm, m_algoVariant, m_threads.mask, m_priority)); m_threads.list.push_back(CpuThread::createFromAV(i, m_algorithm.algo(), m_algoVariant, m_threads.mask, m_priority));
} }
return true; return true;
@ -351,7 +334,7 @@ bool xmrig::Config::parseInt(int key, int arg)
xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
{ {
# ifndef XMRIG_NO_AEON # ifndef XMRIG_NO_AEON
if (m_algorithm == xmrig::CRYPTONIGHT_LITE) { if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) {
return getAlgoVariantLite(); return getAlgoVariantLite();
} }
# endif # endif

View file

@ -47,16 +47,12 @@ constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024;
constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0; constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0;
constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000; constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000;
constexpr const size_t CRYPTONIGHT_IPBC_MEMORY = 1 * 1024 * 1024;
constexpr const uint32_t CRYPTONIGHT_IPBC_MASK = 0xFFFF0;
constexpr const uint32_t CRYPTONIGHT_IPBC_ITER = 0x40000;
template<Algo ALGO> inline constexpr size_t cn_select_memory() { return 0; } template<Algo ALGO> inline constexpr size_t cn_select_memory() { return 0; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT>() { return CRYPTONIGHT_MEMORY; } template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT>() { return CRYPTONIGHT_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MEMORY; } template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MEMORY; } template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_IPBC>() { return CRYPTONIGHT_IPBC_MEMORY; }
inline size_t cn_select_memory(Algo algorithm) inline size_t cn_select_memory(Algo algorithm)
{ {
@ -71,9 +67,6 @@ inline size_t cn_select_memory(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MEMORY; return CRYPTONIGHT_HEAVY_MEMORY;
case CRYPTONIGHT_IPBC:
return CRYPTONIGHT_IPBC_MEMORY;
default: default:
break; break;
} }
@ -86,7 +79,7 @@ template<Algo ALGO> inline constexpr uint32_t cn_select_mask() { retur
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT>() { return CRYPTONIGHT_MASK; } template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT>() { return CRYPTONIGHT_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MASK; } template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MASK; } template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_IPBC>() { return CRYPTONIGHT_IPBC_MASK; }
inline uint32_t cn_select_mask(Algo algorithm) inline uint32_t cn_select_mask(Algo algorithm)
{ {
@ -101,9 +94,6 @@ inline uint32_t cn_select_mask(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MASK; return CRYPTONIGHT_HEAVY_MASK;
case CRYPTONIGHT_IPBC:
return CRYPTONIGHT_IPBC_MASK;
default: default:
break; break;
} }
@ -116,7 +106,7 @@ template<Algo ALGO> inline constexpr uint32_t cn_select_iter() { retur
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT>() { return CRYPTONIGHT_ITER; } template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT>() { return CRYPTONIGHT_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_ITER; } template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_ITER; } template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_IPBC>() { return CRYPTONIGHT_IPBC_ITER; }
inline uint32_t cn_select_iter(Algo algorithm) inline uint32_t cn_select_iter(Algo algorithm)
{ {
@ -131,9 +121,6 @@ inline uint32_t cn_select_iter(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_ITER; return CRYPTONIGHT_HEAVY_ITER;
case CRYPTONIGHT_IPBC:
return CRYPTONIGHT_IPBC_ITER;
default: default:
break; break;
} }

View file

@ -61,7 +61,7 @@ Network::Network(xmrig::Controller *controller) :
} }
if (controller->config()->donateLevel() > 0) { if (controller->config()->donateLevel() > 0) {
m_donate = new DonateStrategy(controller->config()->donateLevel(), controller->config()->pools().front().user(), controller->config()->algorithm(), this); m_donate = new DonateStrategy(controller->config()->donateLevel(), controller->config()->pools().front().user(), controller->config()->algorithm().algo(), this);
} }
m_timer.data = this; m_timer.data = this;
@ -166,9 +166,9 @@ bool Network::isColors() const
void Network::setJob(Client *client, const Job &job, bool donate) void Network::setJob(Client *client, const Job &job, bool donate)
{ {
LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s/%d") LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s")
: "new job from %s:%d diff %d algo %s/%d", : "new job from %s:%d diff %d algo %s",
client->host(), client->port(), job.diff(), Pool::algoName(job.algorithm(), true), static_cast<int>(job.variant())); client->host(), client->port(), job.diff(), job.algorithm().shortName());
m_state.diff = job.diff(); m_state.diff = job.diff();
Workers::setJob(job, donate); Workers::setJob(job, donate);

View file

@ -63,15 +63,12 @@ DonateStrategy::DonateStrategy(int level, const char *user, xmrig::Algo algo, IS
else if (algo == xmrig::CRYPTONIGHT_HEAVY) { else if (algo == xmrig::CRYPTONIGHT_HEAVY) {
m_pools.push_back(Pool(kDonatePool1, 8888, userId, nullptr, false, true)); m_pools.push_back(Pool(kDonatePool1, 8888, userId, nullptr, false, true));
} }
else if (algo == xmrig::CRYPTONIGHT_IPBC) {
m_pools.push_back(Pool(kDonatePool1, 13333, userId, nullptr, false, true));
}
else { else {
m_pools.push_back(Pool(kDonatePool1, 5555, userId, nullptr, false, true)); m_pools.push_back(Pool(kDonatePool1, 5555, userId, nullptr, false, true));
} }
for (Pool &pool : m_pools) { for (Pool &pool : m_pools) {
pool.setAlgo(algo); pool.algorithm().setAlgo(algo);
} }
if (m_pools.size() > 1) { if (m_pools.size() > 1) {

View file

@ -62,69 +62,69 @@ bool xmrig::CpuThread::isSoftAES(AlgoVariant av)
xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant) xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant)
{ {
assert(variant == VARIANT_V0 || variant == VARIANT_V1); assert(variant == VARIANT_0 || variant == VARIANT_1);
static const cn_hash_fun func_table[50] = { static const cn_hash_fun func_table[50] = {
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_V1>, cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_V1>, cryptonight_double_hash<CRYPTONIGHT, false, VARIANT_1>,
cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_V1>, cryptonight_single_hash<CRYPTONIGHT, true, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_V1>, cryptonight_double_hash<CRYPTONIGHT, true, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_V1>, cryptonight_triple_hash<CRYPTONIGHT, false, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_V1>, cryptonight_quad_hash<CRYPTONIGHT, false, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_V1>, cryptonight_penta_hash<CRYPTONIGHT, false, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_V1>, cryptonight_triple_hash<CRYPTONIGHT, true, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_V1>, cryptonight_quad_hash<CRYPTONIGHT, true, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_V1>, cryptonight_penta_hash<CRYPTONIGHT, true, VARIANT_1>,
# ifndef XMRIG_NO_AEON # ifndef XMRIG_NO_AEON
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_V1>, cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_V1>, cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_1>,
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_V1>, cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_V1>, cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_V1>, cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_V1>, cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_V1>, cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_V1>, cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_V1>, cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_V1>, cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
# else # else
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
# endif # endif
# ifndef XMRIG_NO_SUMO # ifndef XMRIG_NO_SUMO
cryptonight_single_hash<CRYPTONIGHT_HEAVY, false, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_HEAVY, false, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT_HEAVY, true, VARIANT_V0>, cryptonight_single_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_HEAVY, true, VARIANT_V0>, cryptonight_double_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, false, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, false, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, false, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_HEAVY, true, VARIANT_V0>, cryptonight_triple_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_HEAVY, true, VARIANT_V0>, cryptonight_quad_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_HEAVY, true, VARIANT_V0>, cryptonight_penta_hash<CRYPTONIGHT_HEAVY, true, VARIANT_0>,
# else # else
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
# endif # endif
@ -132,7 +132,7 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
# ifndef XMRIG_NO_SUMO # ifndef XMRIG_NO_SUMO
if (algorithm == CRYPTONIGHT_HEAVY) { if (algorithm == CRYPTONIGHT_HEAVY) {
variant = VARIANT_V0; variant = VARIANT_0;
} }
# endif # endif
@ -252,7 +252,6 @@ rapidjson::Value xmrig::CpuThread::toAPI(rapidjson::Document &doc) const
auto &allocator = doc.GetAllocator(); auto &allocator = doc.GetAllocator();
obj.AddMember("type", "cpu", allocator); obj.AddMember("type", "cpu", allocator);
obj.AddMember("algo", rapidjson::StringRef(Pool::algoName(algorithm())), allocator);
obj.AddMember("av", m_av, allocator); obj.AddMember("av", m_av, allocator);
obj.AddMember("low_power_mode", multiway(), allocator); obj.AddMember("low_power_mode", multiway(), allocator);
obj.AddMember("affine_to_cpu", affinity(), allocator); obj.AddMember("affine_to_cpu", affinity(), allocator);

View file

@ -50,21 +50,21 @@ MultiWorker<N>::~MultiWorker()
template<size_t N> template<size_t N>
bool MultiWorker<N>::selfTest() bool MultiWorker<N>::selfTest()
{ {
if (m_thread->fn(xmrig::VARIANT_V0) == nullptr) { if (m_thread->fn(xmrig::VARIANT_0) == nullptr) {
return false; return false;
} }
m_thread->fn(xmrig::VARIANT_V0)(test_input, 76, m_hash, m_ctx); m_thread->fn(xmrig::VARIANT_0)(test_input, 76, m_hash, m_ctx);
if (m_thread->algorithm() == xmrig::CRYPTONIGHT && memcmp(m_hash, test_output_v0, sizeof m_hash) == 0) { if (m_thread->algorithm() == xmrig::CRYPTONIGHT && memcmp(m_hash, test_output_v0, sizeof m_hash) == 0) {
m_thread->fn(xmrig::VARIANT_V1)(test_input, 76, m_hash, m_ctx); m_thread->fn(xmrig::VARIANT_1)(test_input, 76, m_hash, m_ctx);
return memcmp(m_hash, test_output_v1, sizeof m_hash) == 0; return memcmp(m_hash, test_output_v1, sizeof m_hash) == 0;
} }
# ifndef XMRIG_NO_AEON # ifndef XMRIG_NO_AEON
if (m_thread->algorithm() == xmrig::CRYPTONIGHT_LITE && memcmp(m_hash, test_output_v0_lite, sizeof m_hash) == 0) { if (m_thread->algorithm() == xmrig::CRYPTONIGHT_LITE && memcmp(m_hash, test_output_v0_lite, sizeof m_hash) == 0) {
m_thread->fn(xmrig::VARIANT_V1)(test_input, 76, m_hash, m_ctx); m_thread->fn(xmrig::VARIANT_1)(test_input, 76, m_hash, m_ctx);
return memcmp(m_hash, test_output_v1_lite, sizeof m_hash) == 0; return memcmp(m_hash, test_output_v1_lite, sizeof m_hash) == 0;
} }

View file

@ -132,7 +132,7 @@ void Workers::setJob(const Job &job, bool donate)
void Workers::start(xmrig::Controller *controller) void Workers::start(xmrig::Controller *controller)
{ {
const std::vector<xmrig::IThread *> &threads = controller->config()->threads(); const std::vector<xmrig::IThread *> &threads = controller->config()->threads();
m_status.algo = controller->config()->algorithm(); m_status.algo = controller->config()->algorithm().algo();
m_status.colors = controller->config()->isColors(); m_status.colors = controller->config()->isColors();
m_status.threads = threads.size(); m_status.threads = threads.size();