Implemented stable algorithm ids.
This commit is contained in:
parent
d0a632f557
commit
e6332eff2b
21 changed files with 6349 additions and 6480 deletions
|
@ -73,16 +73,16 @@ set(HEADERS_BASE
|
|||
src/base/tools/bswap_64.h
|
||||
src/base/tools/Buffer.h
|
||||
src/base/tools/Chrono.h
|
||||
src/base/tools/cryptonote/BlobReader.h
|
||||
src/base/tools/cryptonote/BlockTemplate.h
|
||||
src/base/tools/cryptonote/crypto-ops.h
|
||||
src/base/tools/cryptonote/Signatures.h
|
||||
src/base/tools/cryptonote/umul128.h
|
||||
src/base/tools/cryptonote/WalletAddress.h
|
||||
src/base/tools/Cvt.h
|
||||
src/base/tools/Handle.h
|
||||
src/base/tools/String.h
|
||||
src/base/tools/Timer.h
|
||||
src/base/tools/cryptonote/BlobReader.h
|
||||
src/base/tools/cryptonote/BlockTemplate.h
|
||||
src/base/tools/cryptonote/Signatures.h
|
||||
src/base/tools/cryptonote/WalletAddress.h
|
||||
src/base/tools/cryptonote/crypto-ops.h
|
||||
src/base/tools/cryptonote/umul128.h
|
||||
)
|
||||
|
||||
set(SOURCES_BASE
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* 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 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 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
|
||||
|
@ -23,15 +17,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -42,98 +36,235 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
struct AlgoName
|
||||
{
|
||||
const char *name;
|
||||
const char *shortName;
|
||||
const Algorithm::Id id;
|
||||
const char *Algorithm::kINVALID = "invalid";
|
||||
const char *Algorithm::kCN_0 = "cn/0";
|
||||
const char *Algorithm::kCN_1 = "cn/1";
|
||||
const char *Algorithm::kCN_2 = "cn/2";
|
||||
const char *Algorithm::kCN_R = "cn/r";
|
||||
const char *Algorithm::kCN_FAST = "cn/fast";
|
||||
const char *Algorithm::kCN_HALF = "cn/half";
|
||||
const char *Algorithm::kCN_XAO = "cn/xao";
|
||||
const char *Algorithm::kCN_RTO = "cn/rto";
|
||||
const char *Algorithm::kCN_RWZ = "cn/rwz";
|
||||
const char *Algorithm::kCN_ZLS = "cn/zls";
|
||||
const char *Algorithm::kCN_DOUBLE = "cn/double";
|
||||
const char *Algorithm::kCN_CCX = "cn/ccx";
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_LITE
|
||||
const char *Algorithm::kCN_LITE_0 = "cn-lite/0";
|
||||
const char *Algorithm::kCN_LITE_1 = "cn-lite/1";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_HEAVY
|
||||
const char *Algorithm::kCN_HEAVY_0 = "cn-heavy/0";
|
||||
const char *Algorithm::kCN_HEAVY_TUBE = "cn-heavy/tube";
|
||||
const char *Algorithm::kCN_HEAVY_XHV = "cn-heavy/xhv";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_PICO
|
||||
const char *Algorithm::kCN_PICO_0 = "cn-pico/0";
|
||||
const char *Algorithm::kCN_PICO_TLO = "cn-pico/tlo";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
const char *Algorithm::kCN_UPX2 = "cn/upx2";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
const char *Algorithm::kRX_0 = "rx/0";
|
||||
const char *Algorithm::kRX_WOW = "rx/wow";
|
||||
const char *Algorithm::kRX_ARQ = "rx/arq";
|
||||
const char *Algorithm::kRX_SFX = "rx/sfx";
|
||||
const char *Algorithm::kRX_KEVA = "rx/keva";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ARGON2
|
||||
const char *Algorithm::kAR2_CHUKWA = "argon2/chukwa";
|
||||
const char *Algorithm::kAR2_CHUKWA_V2 = "argon2/chukwav2";
|
||||
const char *Algorithm::kAR2_WRKZ = "argon2/ninja";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ASTROBWT
|
||||
const char *Algorithm::kASTROBWT_DERO = "astrobwt";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_KAWPOW
|
||||
const char *Algorithm::kKAWPOW_RVN = "kawpow";
|
||||
#endif
|
||||
|
||||
|
||||
#define ALGO_NAME(ALGO) { Algorithm::ALGO, Algorithm::k##ALGO }
|
||||
#define ALGO_ALIAS(ALGO, NAME) { NAME, Algorithm::ALGO }
|
||||
#define ALGO_ALIAS_AUTO(ALGO) { Algorithm::k##ALGO, Algorithm::ALGO }
|
||||
|
||||
|
||||
static const std::map<Algorithm::Id, const char *> kAlgorithmNames = {
|
||||
ALGO_NAME(CN_0),
|
||||
ALGO_NAME(CN_1),
|
||||
ALGO_NAME(CN_2),
|
||||
ALGO_NAME(CN_R),
|
||||
ALGO_NAME(CN_FAST),
|
||||
ALGO_NAME(CN_HALF),
|
||||
ALGO_NAME(CN_XAO),
|
||||
ALGO_NAME(CN_RTO),
|
||||
ALGO_NAME(CN_RWZ),
|
||||
ALGO_NAME(CN_ZLS),
|
||||
ALGO_NAME(CN_DOUBLE),
|
||||
ALGO_NAME(CN_CCX),
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
ALGO_NAME(CN_LITE_0),
|
||||
ALGO_NAME(CN_LITE_1),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
ALGO_NAME(CN_HEAVY_0),
|
||||
ALGO_NAME(CN_HEAVY_TUBE),
|
||||
ALGO_NAME(CN_HEAVY_XHV),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
ALGO_NAME(CN_PICO_0),
|
||||
ALGO_NAME(CN_PICO_TLO),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
ALGO_NAME(CN_UPX2),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
ALGO_NAME(RX_0),
|
||||
ALGO_NAME(RX_WOW),
|
||||
ALGO_NAME(RX_ARQ),
|
||||
ALGO_NAME(RX_SFX),
|
||||
ALGO_NAME(RX_KEVA),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
ALGO_NAME(AR2_CHUKWA),
|
||||
ALGO_NAME(AR2_CHUKWA_V2),
|
||||
ALGO_NAME(AR2_WRKZ),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
ALGO_NAME(ASTROBWT_DERO),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
ALGO_NAME(KAWPOW_RVN),
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
static AlgoName const algorithm_names[] = {
|
||||
{ "cryptonight/0", "cn/0", Algorithm::CN_0 },
|
||||
{ "cryptonight", "cn", Algorithm::CN_0 },
|
||||
{ "cryptonight/1", "cn/1", Algorithm::CN_1 },
|
||||
{ "cryptonight-monerov7", nullptr, Algorithm::CN_1 },
|
||||
{ "cryptonight_v7", nullptr, Algorithm::CN_1 },
|
||||
{ "cryptonight/2", "cn/2", Algorithm::CN_2 },
|
||||
{ "cryptonight-monerov8", nullptr, Algorithm::CN_2 },
|
||||
{ "cryptonight_v8", nullptr, Algorithm::CN_2 },
|
||||
{ "cryptonight/r", "cn/r", Algorithm::CN_R },
|
||||
{ "cryptonight_r", nullptr, Algorithm::CN_R },
|
||||
{ "cryptonight/fast", "cn/fast", Algorithm::CN_FAST },
|
||||
{ "cryptonight/msr", "cn/msr", Algorithm::CN_FAST },
|
||||
{ "cryptonight/half", "cn/half", Algorithm::CN_HALF },
|
||||
{ "cryptonight/xao", "cn/xao", Algorithm::CN_XAO },
|
||||
{ "cryptonight_alloy", nullptr, Algorithm::CN_XAO },
|
||||
{ "cryptonight/rto", "cn/rto", Algorithm::CN_RTO },
|
||||
{ "cryptonight/rwz", "cn/rwz", Algorithm::CN_RWZ },
|
||||
{ "cryptonight/zls", "cn/zls", Algorithm::CN_ZLS },
|
||||
{ "cryptonight/double", "cn/double", Algorithm::CN_DOUBLE },
|
||||
struct aliasCompare
|
||||
{
|
||||
inline bool operator()(const char *a, const char *b) const { return std::strcmp(a, b) < 0; }
|
||||
};
|
||||
|
||||
|
||||
static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAliases = {
|
||||
ALGO_ALIAS_AUTO(CN_0), ALGO_ALIAS(CN_0, "cryptonight/0"),
|
||||
ALGO_ALIAS(CN_0, "cryptonight"),
|
||||
ALGO_ALIAS(CN_0, "cn"),
|
||||
ALGO_ALIAS_AUTO(CN_1), ALGO_ALIAS(CN_1, "cryptonight/1"),
|
||||
ALGO_ALIAS(CN_1, "cryptonight-monerov7"),
|
||||
ALGO_ALIAS(CN_1, "cryptonight_v7"),
|
||||
ALGO_ALIAS_AUTO(CN_2), ALGO_ALIAS(CN_2, "cryptonight/2"),
|
||||
ALGO_ALIAS(CN_2, "cryptonight-monerov8"),
|
||||
ALGO_ALIAS(CN_2, "cryptonight_v8"),
|
||||
ALGO_ALIAS_AUTO(CN_FAST), ALGO_ALIAS(CN_FAST, "cryptonight/fast"),
|
||||
ALGO_ALIAS(CN_FAST, "cryptonight/msr"),
|
||||
ALGO_ALIAS(CN_FAST, "cn/msr"),
|
||||
ALGO_ALIAS_AUTO(CN_R), ALGO_ALIAS(CN_R, "cryptonight/r"),
|
||||
ALGO_ALIAS(CN_R, "cryptonight_r"),
|
||||
ALGO_ALIAS_AUTO(CN_XAO), ALGO_ALIAS(CN_XAO, "cryptonight/xao"),
|
||||
ALGO_ALIAS(CN_XAO, "cryptonight_alloy"),
|
||||
ALGO_ALIAS_AUTO(CN_HALF), ALGO_ALIAS(CN_HALF, "cryptonight/half"),
|
||||
ALGO_ALIAS_AUTO(CN_RTO), ALGO_ALIAS(CN_RTO, "cryptonight/rto"),
|
||||
ALGO_ALIAS_AUTO(CN_RWZ), ALGO_ALIAS(CN_RWZ, "cryptonight/rwz"),
|
||||
ALGO_ALIAS_AUTO(CN_ZLS), ALGO_ALIAS(CN_ZLS, "cryptonight/zls"),
|
||||
ALGO_ALIAS_AUTO(CN_DOUBLE), ALGO_ALIAS(CN_DOUBLE, "cryptonight/double"),
|
||||
ALGO_ALIAS_AUTO(CN_CCX), ALGO_ALIAS(CN_CCX, "cryptonight/ccx"),
|
||||
ALGO_ALIAS(CN_CCX, "cryptonight/conceal"),
|
||||
ALGO_ALIAS(CN_CCX, "cn/conceal"),
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
{ "cryptonight-lite/0", "cn-lite/0", Algorithm::CN_LITE_0 },
|
||||
{ "cryptonight-lite/1", "cn-lite/1", Algorithm::CN_LITE_1 },
|
||||
{ "cryptonight-lite", "cn-lite", Algorithm::CN_LITE_1 },
|
||||
{ "cryptonight-light", "cn-light", Algorithm::CN_LITE_1 },
|
||||
{ "cryptonight_lite", nullptr, Algorithm::CN_LITE_1 },
|
||||
{ "cryptonight-aeonv7", nullptr, Algorithm::CN_LITE_1 },
|
||||
{ "cryptonight_lite_v7", nullptr, Algorithm::CN_LITE_1 },
|
||||
ALGO_ALIAS_AUTO(CN_LITE_0), ALGO_ALIAS(CN_LITE_0, "cryptonight-lite/0"),
|
||||
ALGO_ALIAS(CN_LITE_0, "cryptonight-lite"),
|
||||
ALGO_ALIAS(CN_LITE_0, "cryptonight-light"),
|
||||
ALGO_ALIAS(CN_LITE_0, "cn-lite"),
|
||||
ALGO_ALIAS(CN_LITE_0, "cn-light"),
|
||||
ALGO_ALIAS(CN_LITE_0, "cryptonight_lite"),
|
||||
ALGO_ALIAS_AUTO(CN_LITE_1), ALGO_ALIAS(CN_LITE_1, "cryptonight-lite/1"),
|
||||
ALGO_ALIAS(CN_LITE_1, "cryptonight-aeonv7"),
|
||||
ALGO_ALIAS(CN_LITE_1, "cryptonight_lite_v7"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
{ "cryptonight-heavy/0", "cn-heavy/0", Algorithm::CN_HEAVY_0 },
|
||||
{ "cryptonight-heavy", "cn-heavy", Algorithm::CN_HEAVY_0 },
|
||||
{ "cryptonight_heavy", nullptr, Algorithm::CN_HEAVY_0 },
|
||||
{ "cryptonight-heavy/xhv", "cn-heavy/xhv", Algorithm::CN_HEAVY_XHV },
|
||||
{ "cryptonight_haven", nullptr, Algorithm::CN_HEAVY_XHV },
|
||||
{ "cryptonight-heavy/tube", "cn-heavy/tube", Algorithm::CN_HEAVY_TUBE },
|
||||
{ "cryptonight-bittube2", nullptr, Algorithm::CN_HEAVY_TUBE },
|
||||
ALGO_ALIAS_AUTO(CN_HEAVY_0), ALGO_ALIAS(CN_HEAVY_0, "cryptonight-heavy/0"),
|
||||
ALGO_ALIAS(CN_HEAVY_0, "cryptonight-heavy"),
|
||||
ALGO_ALIAS(CN_HEAVY_0, "cn-heavy"),
|
||||
ALGO_ALIAS(CN_HEAVY_0, "cryptonight_heavy"),
|
||||
ALGO_ALIAS_AUTO(CN_HEAVY_XHV), ALGO_ALIAS(CN_HEAVY_XHV, "cryptonight-heavy/xhv"),
|
||||
ALGO_ALIAS(CN_HEAVY_XHV, "cryptonight_haven"),
|
||||
ALGO_ALIAS_AUTO(CN_HEAVY_TUBE), ALGO_ALIAS(CN_HEAVY_TUBE, "cryptonight-heavy/tube"),
|
||||
ALGO_ALIAS(CN_HEAVY_TUBE, "cryptonight-bittube2"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
{ "cryptonight-pico", "cn-pico", Algorithm::CN_PICO_0 },
|
||||
{ "cryptonight-pico/trtl", "cn-pico/trtl", Algorithm::CN_PICO_0 },
|
||||
{ "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO_0 },
|
||||
{ "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO_0 },
|
||||
{ "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO_0 },
|
||||
{ "cryptonight-pico/tlo", "cn-pico/tlo", Algorithm::CN_PICO_TLO },
|
||||
{ "cryptonight/ultra", "cn/ultra", Algorithm::CN_PICO_TLO },
|
||||
{ "cryptonight-talleo", "cn-talleo", Algorithm::CN_PICO_TLO },
|
||||
{ "cryptonight_talleo", "cn_talleo", Algorithm::CN_PICO_TLO },
|
||||
ALGO_ALIAS_AUTO(CN_PICO_0), ALGO_ALIAS(CN_PICO_0, "cryptonight-pico"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cn-pico"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cryptonight-pico/trtl"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cn-pico/trtl"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cryptonight-turtle"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cn-trtl"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cryptonight-ultralite"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cn-ultralite"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cryptonight_turtle"),
|
||||
ALGO_ALIAS(CN_PICO_0, "cn_turtle"),
|
||||
ALGO_ALIAS_AUTO(CN_PICO_TLO), ALGO_ALIAS(CN_PICO_TLO, "cryptonight-pico/tlo"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cryptonight/ultra"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cn/ultra"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cryptonight-talleo"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cn-talleo"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cryptonight_talleo"),
|
||||
ALGO_ALIAS(CN_PICO_TLO, "cn_talleo"),
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
{ "randomx/0", "rx/0", Algorithm::RX_0 },
|
||||
{ "randomx/test", "rx/test", Algorithm::RX_0 },
|
||||
{ "RandomX", "rx", Algorithm::RX_0 },
|
||||
{ "randomx/wow", "rx/wow", Algorithm::RX_WOW },
|
||||
{ "RandomWOW", nullptr, Algorithm::RX_WOW },
|
||||
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
||||
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
||||
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
|
||||
{ "RandomSFX", nullptr, Algorithm::RX_SFX },
|
||||
{ "randomx/keva", "rx/keva", Algorithm::RX_KEVA },
|
||||
{ "RandomKEVA", nullptr, Algorithm::RX_KEVA },
|
||||
# endif
|
||||
# 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/ninja", nullptr, Algorithm::AR2_WRKZ },
|
||||
{ "argon2/wrkz", nullptr, Algorithm::AR2_WRKZ },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
{ "astrobwt", nullptr, Algorithm::ASTROBWT_DERO },
|
||||
{ "astrobwt/dero", nullptr, Algorithm::ASTROBWT_DERO },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
{ "kawpow", nullptr, Algorithm::KAWPOW_RVN },
|
||||
{ "kawpow/rvn", nullptr, Algorithm::KAWPOW_RVN },
|
||||
# endif
|
||||
{ "cryptonight/ccx", "cn/ccx", Algorithm::CN_CCX },
|
||||
{ "cryptonight/conceal", "cn/conceal", Algorithm::CN_CCX },
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
{ "cryptonight/upx2", "cn/upx2", Algorithm::CN_UPX2 },
|
||||
{ "cn-extremelite/upx2", nullptr, Algorithm::CN_UPX2 },
|
||||
{ "cryptonight-upx/2", nullptr, Algorithm::CN_UPX2 },
|
||||
ALGO_ALIAS_AUTO(CN_UPX2), ALGO_ALIAS(CN_UPX2, "cryptonight/upx2"),
|
||||
ALGO_ALIAS(CN_UPX2, "cn-extremelite/upx2"),
|
||||
ALGO_ALIAS(CN_UPX2, "cryptonight-upx/2"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
ALGO_ALIAS_AUTO(RX_0), ALGO_ALIAS(RX_0, "randomx/0"),
|
||||
ALGO_ALIAS(RX_0, "randomx/test"),
|
||||
ALGO_ALIAS(RX_0, "rx/test"),
|
||||
ALGO_ALIAS(RX_0, "randomx"),
|
||||
ALGO_ALIAS(RX_0, "rx"),
|
||||
ALGO_ALIAS_AUTO(RX_WOW), ALGO_ALIAS(RX_WOW, "randomx/wow"),
|
||||
ALGO_ALIAS(RX_WOW, "randomwow"),
|
||||
ALGO_ALIAS_AUTO(RX_ARQ), ALGO_ALIAS(RX_ARQ, "randomx/arq"),
|
||||
ALGO_ALIAS(RX_ARQ, "randomarq"),
|
||||
ALGO_ALIAS_AUTO(RX_SFX), ALGO_ALIAS(RX_SFX, "randomx/sfx"),
|
||||
ALGO_ALIAS(RX_SFX, "randomsfx"),
|
||||
ALGO_ALIAS_AUTO(RX_KEVA), ALGO_ALIAS(RX_KEVA, "randomx/keva"),
|
||||
ALGO_ALIAS(RX_KEVA, "randomkeva"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
ALGO_ALIAS_AUTO(AR2_CHUKWA), ALGO_ALIAS(AR2_CHUKWA, "chukwa"),
|
||||
ALGO_ALIAS_AUTO(AR2_CHUKWA_V2), ALGO_ALIAS(AR2_CHUKWA, "chukwav2"),
|
||||
ALGO_ALIAS_AUTO(AR2_WRKZ), ALGO_ALIAS(AR2_WRKZ, "argon2/wrkz"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
ALGO_ALIAS_AUTO(ASTROBWT_DERO), ALGO_ALIAS(ASTROBWT_DERO, "astrobwt/dero"),
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
ALGO_ALIAS_AUTO(KAWPOW_RVN), ALGO_ALIAS(KAWPOW_RVN, "kawpow/rvn"),
|
||||
# endif
|
||||
};
|
||||
|
||||
|
@ -147,11 +278,24 @@ xmrig::Algorithm::Algorithm(const rapidjson::Value &value) :
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::Algorithm::name() const
|
||||
{
|
||||
if (!isValid()) {
|
||||
return kINVALID;
|
||||
}
|
||||
|
||||
assert(kAlgorithmNames.count(m_id));
|
||||
const auto it = kAlgorithmNames.find(m_id);
|
||||
|
||||
return it != kAlgorithmNames.end() ? it->second : kINVALID;
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Algorithm::toJSON() const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
return isValid() ? Value(StringRef(shortName())) : Value(kNullType);
|
||||
return isValid() ? Value(StringRef(name())) : Value(kNullType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,245 +305,47 @@ rapidjson::Value xmrig::Algorithm::toJSON(rapidjson::Document &) const
|
|||
}
|
||||
|
||||
|
||||
size_t xmrig::Algorithm::l2() const
|
||||
{
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_SFX:
|
||||
return 0x40000;
|
||||
|
||||
case RX_WOW:
|
||||
case RX_KEVA:
|
||||
return 0x20000;
|
||||
|
||||
case RX_ARQ:
|
||||
return 0x10000;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::Algorithm::l3() const
|
||||
{
|
||||
constexpr size_t oneMiB = 0x100000;
|
||||
|
||||
const auto f = family();
|
||||
assert(f != UNKNOWN);
|
||||
|
||||
switch (f) {
|
||||
case CN:
|
||||
return oneMiB * 2;
|
||||
|
||||
case CN_LITE:
|
||||
return oneMiB;
|
||||
|
||||
case CN_HEAVY:
|
||||
return oneMiB * 4;
|
||||
|
||||
case CN_PICO:
|
||||
return oneMiB / 4;
|
||||
|
||||
case CN_FEMTO:
|
||||
return oneMiB / 8;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (f == RANDOM_X) {
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_SFX:
|
||||
return oneMiB * 2;
|
||||
|
||||
case RX_WOW:
|
||||
case RX_KEVA:
|
||||
return oneMiB;
|
||||
|
||||
case RX_ARQ:
|
||||
return oneMiB / 4;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (f == ARGON2) {
|
||||
switch (m_id) {
|
||||
case AR2_CHUKWA:
|
||||
return oneMiB / 2;
|
||||
|
||||
case AR2_CHUKWA_V2:
|
||||
return oneMiB;
|
||||
|
||||
case AR2_WRKZ:
|
||||
return oneMiB / 4;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (f == ASTROBWT) {
|
||||
switch (m_id) {
|
||||
case ASTROBWT_DERO:
|
||||
return oneMiB * 20;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
if (f == KAWPOW) {
|
||||
switch (m_id) {
|
||||
case KAWPOW_RVN:
|
||||
return 32768;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint32_t xmrig::Algorithm::maxIntensity() const
|
||||
{
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (family() == RANDOM_X) {
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (family() == ARGON2) {
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (family() == ASTROBWT) {
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
||||
{
|
||||
switch (id) {
|
||||
case CN_0:
|
||||
case CN_1:
|
||||
case CN_2:
|
||||
case CN_R:
|
||||
case CN_FAST:
|
||||
case CN_HALF:
|
||||
case CN_XAO:
|
||||
case CN_RTO:
|
||||
case CN_RWZ:
|
||||
case CN_ZLS:
|
||||
case CN_DOUBLE:
|
||||
case CN_CCX:
|
||||
return CN;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
case CN_LITE_0:
|
||||
case CN_LITE_1:
|
||||
return CN_LITE;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
case CN_HEAVY_0:
|
||||
case CN_HEAVY_TUBE:
|
||||
case CN_HEAVY_XHV:
|
||||
return CN_HEAVY;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
case CN_PICO_0:
|
||||
case CN_PICO_TLO:
|
||||
return CN_PICO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
case CN_UPX2:
|
||||
return CN_FEMTO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
case RX_0:
|
||||
case RX_WOW:
|
||||
case RX_ARQ:
|
||||
case RX_SFX:
|
||||
case RX_KEVA:
|
||||
return RANDOM_X;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
case AR2_CHUKWA:
|
||||
case AR2_CHUKWA_V2:
|
||||
case AR2_WRKZ:
|
||||
return ARGON2;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
case ASTROBWT_DERO:
|
||||
return ASTROBWT;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
case KAWPOW_RVN:
|
||||
return KAWPOW;
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name)
|
||||
{
|
||||
if (name == nullptr || strlen(name) < 1) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
for (const AlgoName &item : algorithm_names) {
|
||||
if ((strcasecmp(name, item.name) == 0) || (item.shortName != nullptr && strcasecmp(name, item.shortName) == 0)) {
|
||||
return item.id;
|
||||
}
|
||||
}
|
||||
const auto it = kAlgorithmAliases.find(String(name).toLower());
|
||||
|
||||
return INVALID;
|
||||
return it != kAlgorithmAliases.end() ? it->second : INVALID;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::Algorithm::name(bool shortName) const
|
||||
size_t xmrig::Algorithm::count()
|
||||
{
|
||||
for (const AlgoName &item : algorithm_names) {
|
||||
if (item.id == m_id) {
|
||||
return (shortName && item.shortName) ? item.shortName : item.name;
|
||||
return kAlgorithmNames.size();
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::Algorithm> xmrig::Algorithm::all()
|
||||
{
|
||||
Algorithms out;
|
||||
out.reserve(count());
|
||||
|
||||
for (const auto &kv : kAlgorithmNames) {
|
||||
out.emplace_back(kv.first);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::vector<xmrig::Algorithm> xmrig::Algorithm::all(const std::function<bool(const Algorithm &algo)> &filter)
|
||||
{
|
||||
Algorithms out;
|
||||
out.reserve(count());
|
||||
|
||||
for (const auto &kv : kAlgorithmNames) {
|
||||
if (filter(kv.first)) {
|
||||
out.emplace_back(kv.first);
|
||||
}
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
/* 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 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 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
|
||||
|
@ -27,6 +21,7 @@
|
|||
#define XMRIG_ALGORITHM_H
|
||||
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
@ -39,89 +34,165 @@ namespace xmrig {
|
|||
class Algorithm
|
||||
{
|
||||
public:
|
||||
// Changes in following file is required if this enum changed:
|
||||
// Changes in following file may required if this enum changed:
|
||||
//
|
||||
// src/backend/opencl/cl/cn/algorithm.cl
|
||||
//
|
||||
enum Id : int {
|
||||
INVALID = -1,
|
||||
CN_0, // "cn/0" CryptoNight (original).
|
||||
CN_1, // "cn/1" CryptoNight variant 1 also known as Monero7 and CryptoNightV7.
|
||||
CN_2, // "cn/2" CryptoNight variant 2.
|
||||
CN_R, // "cn/r" CryptoNightR (Monero's variant 4).
|
||||
CN_FAST, // "cn/fast" CryptoNight variant 1 with half iterations.
|
||||
CN_HALF, // "cn/half" CryptoNight variant 2 with half iterations (Masari/Torque).
|
||||
CN_XAO, // "cn/xao" CryptoNight variant 0 (modified, Alloy only).
|
||||
CN_RTO, // "cn/rto" CryptoNight variant 1 (modified, Arto only).
|
||||
CN_RWZ, // "cn/rwz" CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft).
|
||||
CN_ZLS, // "cn/zls" CryptoNight variant 2 with 3/4 iterations (Zelerius).
|
||||
CN_DOUBLE, // "cn/double" CryptoNight variant 2 with double iterations (X-CASH).
|
||||
CN_LITE_0, // "cn-lite/0" CryptoNight-Lite variant 0.
|
||||
CN_LITE_1, // "cn-lite/1" CryptoNight-Lite variant 1.
|
||||
CN_HEAVY_0, // "cn-heavy/0" CryptoNight-Heavy (4 MB).
|
||||
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
||||
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
|
||||
CN_PICO_0, // "cn-pico" CryptoNight-Pico
|
||||
CN_PICO_TLO, // "cn-pico/tlo" CryptoNight-Pico (TLO)
|
||||
CN_CCX, // "cn/ccx" Conceal (CCX)
|
||||
CN_UPX2, // "cn/upx2" Uplexa (UPX2)
|
||||
RX_0, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
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)
|
||||
MAX
|
||||
// Id encoding:
|
||||
// 1 byte: family
|
||||
// 1 byte: L3 memory as power of 2 (if applicable).
|
||||
// 1 byte: L2 memory for RandomX algorithms as power of 2, base variant for CryptoNight algorithms or 0x00.
|
||||
// 1 byte: extra variant (coin) id.
|
||||
enum Id : uint32_t {
|
||||
INVALID = 0,
|
||||
CN_0 = 0x63150000, // "cn/0" CryptoNight (original).
|
||||
CN_1 = 0x63150100, // "cn/1" CryptoNight variant 1 also known as Monero7 and CryptoNightV7.
|
||||
CN_2 = 0x63150200, // "cn/2" CryptoNight variant 2.
|
||||
CN_R = 0x63150272, // "cn/r" CryptoNightR (Monero's variant 4).
|
||||
CN_FAST = 0x63150166, // "cn/fast" CryptoNight variant 1 with half iterations.
|
||||
CN_HALF = 0x63150268, // "cn/half" CryptoNight variant 2 with half iterations (Masari/Torque).
|
||||
CN_XAO = 0x63150078, // "cn/xao" CryptoNight variant 0 (modified, Alloy only).
|
||||
CN_RTO = 0x63150172, // "cn/rto" CryptoNight variant 1 (modified, Arto only).
|
||||
CN_RWZ = 0x63150277, // "cn/rwz" CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft).
|
||||
CN_ZLS = 0x6315027a, // "cn/zls" CryptoNight variant 2 with 3/4 iterations (Zelerius).
|
||||
CN_DOUBLE = 0x63150264, // "cn/double" CryptoNight variant 2 with double iterations (X-CASH).
|
||||
CN_CCX = 0x63150063, // "cn/ccx" Conceal (CCX)
|
||||
CN_LITE_0 = 0x63140000, // "cn-lite/0" CryptoNight-Lite variant 0.
|
||||
CN_LITE_1 = 0x63140100, // "cn-lite/1" CryptoNight-Lite variant 1.
|
||||
CN_HEAVY_0 = 0x63160000, // "cn-heavy/0" CryptoNight-Heavy (4 MB).
|
||||
CN_HEAVY_TUBE = 0x63160172, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
||||
CN_HEAVY_XHV = 0x63160068, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
|
||||
CN_PICO_0 = 0x63120200, // "cn-pico" CryptoNight-Pico
|
||||
CN_PICO_TLO = 0x63120274, // "cn-pico/tlo" CryptoNight-Pico (TLO)
|
||||
CN_UPX2 = 0x63110200, // "cn/upx2" Uplexa (UPX2)
|
||||
RX_0 = 0x72151200, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW = 0x72141177, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_ARQ = 0x72121061, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_SFX = 0x72151273, // "rx/sfx" RandomSFX (Safex Cash).
|
||||
RX_KEVA = 0x7214116b, // "rx/keva" RandomKEVA (Keva).
|
||||
AR2_CHUKWA = 0x61130000, // "argon2/chukwa" Argon2id (Chukwa).
|
||||
AR2_CHUKWA_V2 = 0x61140000, // "argon2/chukwav2" Argon2id (Chukwa v2).
|
||||
AR2_WRKZ = 0x61120000, // "argon2/wrkz" Argon2id (WRKZ)
|
||||
ASTROBWT_DERO = 0x41000000, // "astrobwt" AstroBWT (Dero)
|
||||
KAWPOW_RVN = 0x6b0f0000, // "kawpow/rvn" KawPow (RVN)
|
||||
};
|
||||
|
||||
enum Family : int {
|
||||
UNKNOWN,
|
||||
CN,
|
||||
CN_LITE,
|
||||
CN_HEAVY,
|
||||
CN_PICO,
|
||||
CN_FEMTO,
|
||||
RANDOM_X,
|
||||
ARGON2,
|
||||
ASTROBWT,
|
||||
KAWPOW
|
||||
enum Family : uint32_t {
|
||||
UNKNOWN = 0,
|
||||
CN_ANY = 0x63000000,
|
||||
CN = 0x63150000,
|
||||
CN_LITE = 0x63140000,
|
||||
CN_HEAVY = 0x63160000,
|
||||
CN_PICO = 0x63120200,
|
||||
CN_FEMTO = 0x63110200,
|
||||
RANDOM_X = 0x72000000,
|
||||
ARGON2 = 0x61000000,
|
||||
ASTROBWT = 0x41000000,
|
||||
KAWPOW = 0x6b000000
|
||||
};
|
||||
|
||||
static const char *kINVALID;
|
||||
static const char *kCN_0;
|
||||
static const char *kCN_1;
|
||||
static const char *kCN_2;
|
||||
static const char *kCN_R;
|
||||
static const char *kCN_FAST;
|
||||
static const char *kCN_HALF;
|
||||
static const char *kCN_XAO;
|
||||
static const char *kCN_RTO;
|
||||
static const char *kCN_RWZ;
|
||||
static const char *kCN_ZLS;
|
||||
static const char *kCN_DOUBLE;
|
||||
static const char *kCN_CCX;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
static const char *kCN_LITE_0;
|
||||
static const char *kCN_LITE_1;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
static const char *kCN_HEAVY_0;
|
||||
static const char *kCN_HEAVY_TUBE;
|
||||
static const char *kCN_HEAVY_XHV;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
static const char *kCN_PICO_0;
|
||||
static const char *kCN_PICO_TLO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
static const char *kCN_UPX2;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
static const char *kRX_0;
|
||||
static const char *kRX_WOW;
|
||||
static const char *kRX_ARQ;
|
||||
static const char *kRX_SFX;
|
||||
static const char *kRX_KEVA;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
static const char *kAR2_CHUKWA;
|
||||
static const char *kAR2_CHUKWA_V2;
|
||||
static const char *kAR2_WRKZ;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
static const char *kASTROBWT_DERO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
static const char *kKAWPOW_RVN;
|
||||
# endif
|
||||
|
||||
inline Algorithm() = default;
|
||||
inline Algorithm(const char *algo) : m_id(parse(algo)) {}
|
||||
inline Algorithm(Id id) : m_id(id) {}
|
||||
inline Algorithm(const char *algo) : m_id(parse(algo)) {}
|
||||
inline Algorithm(Id id) : m_id(id) {}
|
||||
Algorithm(const rapidjson::Value &value);
|
||||
|
||||
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO || f == CN_FEMTO; }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
|
||||
inline bool isValid() const { return m_id != INVALID && family() != UNKNOWN; }
|
||||
inline const char *name() const { return name(false); }
|
||||
inline const char *shortName() const { return name(true); }
|
||||
inline Family family() const { return family(m_id); }
|
||||
inline Id id() const { return m_id; }
|
||||
static inline constexpr bool isCN(Id id) { return (id & 0xff000000) == CN_ANY; }
|
||||
static inline constexpr Id base(Id id) { return isCN(id) ? static_cast<Id>(CN_0 | (id & 0xff00)) : INVALID; }
|
||||
static inline constexpr size_t l2(Id id) { return family(id) == RANDOM_X ? (1U << ((id >> 8) & 0xff)) : 0U; }
|
||||
static inline constexpr size_t l3(Id id) { return 1U << ((id >> 16) & 0xff); }
|
||||
static inline constexpr uint32_t family(Id id) { return id & (isCN(id) ? 0xffff0000 : 0xff000000); }
|
||||
|
||||
inline bool operator!=(Algorithm::Id id) const { return m_id != id; }
|
||||
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
|
||||
inline bool operator==(Algorithm::Id id) const { return m_id == id; }
|
||||
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
|
||||
inline operator Algorithm::Id() const { return m_id; }
|
||||
inline bool isCN() const { return isCN(m_id); }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
|
||||
inline bool isValid() const { return m_id != INVALID && family() > UNKNOWN; }
|
||||
inline const char *shortName() const { return name(); }
|
||||
inline Id base() const { return base(m_id); }
|
||||
inline Id id() const { return m_id; }
|
||||
inline size_t l2() const { return l2(m_id); }
|
||||
inline uint32_t family() const { return family(m_id); }
|
||||
inline uint32_t maxIntensity() const { return isCN() ? 5 : 1; };
|
||||
|
||||
inline size_t l3() const
|
||||
{
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
return m_id != ASTROBWT_DERO ? l3(m_id) : 0x100000 * 20;
|
||||
# else
|
||||
return l3(m_id);
|
||||
# endif
|
||||
}
|
||||
|
||||
inline bool operator!=(Algorithm::Id id) const { return m_id != id; }
|
||||
inline bool operator!=(const Algorithm &other) const { return !isEqual(other); }
|
||||
inline bool operator==(Algorithm::Id id) const { return m_id == id; }
|
||||
inline bool operator==(const Algorithm &other) const { return isEqual(other); }
|
||||
inline operator Algorithm::Id() const { return m_id; }
|
||||
|
||||
const char *name() const;
|
||||
rapidjson::Value toJSON() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t l2() const;
|
||||
size_t l3() const;
|
||||
uint32_t maxIntensity() const;
|
||||
|
||||
static Family family(Id id);
|
||||
static Id parse(const char *name);
|
||||
static size_t count();
|
||||
static std::vector<Algorithm> all();
|
||||
static std::vector<Algorithm> all(const std::function<bool(const Algorithm &algo)> &filter);
|
||||
|
||||
private:
|
||||
const char *name(bool shortName) const;
|
||||
|
||||
Id m_id = INVALID;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue