1
0
mirror of https://github.com/xmrig/xmrig.git synced 2026-06-24 20:42:39 -04:00

Merge xmrig v6.15.0 into master

This commit is contained in:
MoneroOcean
2021-08-31 16:45:39 +00:00
258 changed files with 13719 additions and 8163 deletions

View File

@@ -79,6 +79,7 @@ const char *Algorithm::kRX = "rx";
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_GRAFT = "rx/graft";
const char *Algorithm::kRX_SFX = "rx/sfx";
const char *Algorithm::kRX_KEVA = "rx/keva";
#endif
@@ -112,11 +113,6 @@ const char *Algorithm::kRX_XLA = "panthera";
#define ALGO_ALIAS_AUTO(ALGO) { Algorithm::k##ALGO, Algorithm::ALGO }
#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif
static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(CN_0),
ALGO_NAME(CN_1),
@@ -155,6 +151,7 @@ static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(RX_0),
ALGO_NAME(RX_WOW),
ALGO_NAME(RX_ARQ),
ALGO_NAME(RX_GRAFT),
ALGO_NAME(RX_SFX),
ALGO_NAME(RX_KEVA),
# endif
@@ -271,6 +268,8 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAlias
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_GRAFT), ALGO_ALIAS(RX_GRAFT, "randomx/graft"),
ALGO_ALIAS(RX_GRAFT, "randomgraft"),
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"),
@@ -370,7 +369,7 @@ std::vector<xmrig::Algorithm> xmrig::Algorithm::all(const std::function<bool(con
CN_PICO_0, CN_PICO_TLO,
CN_UPX2,
CN_GPU, RX_XLA,
RX_0, RX_WOW, RX_ARQ, RX_SFX, RX_KEVA,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_KEVA,
AR2_CHUKWA, AR2_CHUKWA_V2, AR2_WRKZ,
ASTROBWT_DERO,
KAWPOW_RVN

View File

@@ -68,6 +68,7 @@ public:
RX_0 = 0x72151200, // "rx/0" RandomX (reference configuration).
RX_WOW = 0x72141177, // "rx/wow" RandomWOW (Wownero).
RX_ARQ = 0x72121061, // "rx/arq" RandomARQ (Arqma).
RX_GRAFT = 0x72151267, // "rx/graft" RandomGRAFT (Graft).
RX_SFX = 0x72151273, // "rx/sfx" RandomSFX (Safex Cash).
RX_KEVA = 0x7214116b, // "rx/keva" RandomKEVA (Keva).
AR2_CHUKWA = 0x61130000, // "argon2/chukwa" Argon2id (Chukwa).
@@ -137,6 +138,7 @@ public:
static const char *kRX_0;
static const char *kRX_WOW;
static const char *kRX_ARQ;
static const char *kRX_GRAFT;
static const char *kRX_SFX;
static const char *kRX_KEVA;
# endif
@@ -174,7 +176,7 @@ public:
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 size_t l3(Id id) { return 1ULL << ((id >> 16) & 0xff); }
static inline constexpr uint32_t family(Id id) { return id & (isCN(id) ? 0xffff0000 : 0xff000000); }
inline bool isCN() const { return isCN(m_id); }

View File

@@ -1,13 +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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* 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,9 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base/crypto/Coin.h"
#include "3rdparty/rapidjson/document.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include <cstring>
@@ -39,74 +33,66 @@
namespace xmrig {
struct CoinName
struct CoinInfo
{
const Algorithm::Id algorithm;
const char *code;
const char *name;
const Coin::Id id;
const uint64_t target;
const uint64_t units;
const char *tag;
};
static CoinName const coin_names[] = {
{ "monero", Coin::MONERO },
{ "xmr", Coin::MONERO },
{ "arqma", Coin::ARQ },
{ "arq", Coin::ARQ },
{ "dero", Coin::DERO },
{ "keva", Coin::KEVA },
{ "ravencoin", Coin::RAVEN },
{ "raven", Coin::RAVEN },
{ "rvn", Coin::RAVEN },
{ "conceal", Coin::CONCEAL },
{ "wownero", Coin::WOWNERO }
static const CoinInfo coinInfo[] = {
{ Algorithm::INVALID, nullptr, nullptr, 0, 0, nullptr },
{ Algorithm::RX_0, "XMR", "Monero", 120, 1000000000000, YELLOW_BG_BOLD( WHITE_BOLD_S " monero ") },
{ Algorithm::CN_R, "SUMO", "Sumokoin", 240, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " sumo ") },
{ Algorithm::RX_ARQ, "ARQ", "ArQmA", 120, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " arqma ") },
{ Algorithm::ASTROBWT_DERO, "DERO", "DERO", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " dero ") },
{ Algorithm::RX_GRAFT, "GRFT", "Graft", 120, 10000000000, BLUE_BG_BOLD( WHITE_BOLD_S " graft ") },
{ Algorithm::RX_KEVA, "KVA", "Kevacoin", 0, 0, MAGENTA_BG_BOLD(WHITE_BOLD_S " keva ") },
{ Algorithm::KAWPOW_RVN, "RVN", "Ravencoin", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " raven ") },
{ Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") },
};
static_assert(Coin::MAX == sizeof(coinInfo) / sizeof(coinInfo[0]), "size mismatch");
const char *Coin::kDisabled = "DISABLED_COIN";
const char *Coin::kField = "coin";
const char *Coin::kUnknown = "UNKNOWN_COIN";
} /* namespace xmrig */
xmrig::Algorithm::Id xmrig::Coin::algorithm(uint8_t blobVersion) const
xmrig::Coin::Coin(const rapidjson::Value &value)
{
switch (id()) {
case MONERO:
return (blobVersion >= 12) ? Algorithm::RX_0 : Algorithm::CN_R;
case ARQ:
return (blobVersion >= 15) ? Algorithm::RX_ARQ : Algorithm::CN_PICO_0;
case DERO:
return (blobVersion >= 4) ? Algorithm::ASTROBWT_DERO : Algorithm::CN_0;
case KEVA:
return (blobVersion >= 11) ? Algorithm::RX_KEVA : Algorithm::CN_R;
case RAVEN:
return Algorithm::KAWPOW_RVN;
case CONCEAL:
return Algorithm::CN_CCX;
case WOWNERO:
return Algorithm::RX_WOW;
case INVALID:
break;
if (value.IsString()) {
m_id = parse(value.GetString());
}
else if (value.IsObject() && !value.ObjectEmpty()) {
m_id = parse(Json::getString(value, kField));
}
return Algorithm::INVALID;
}
xmrig::Algorithm xmrig::Coin::algorithm(uint8_t) const
{
return coinInfo[m_id].algorithm;
}
const char *xmrig::Coin::code() const
{
return coinInfo[m_id].code;
}
const char *xmrig::Coin::name() const
{
for (const auto &i : coin_names) {
if (i.id == m_id) {
return i.name;
}
}
return nullptr;
return coinInfo[m_id].name;
}
@@ -114,7 +100,19 @@ rapidjson::Value xmrig::Coin::toJSON() const
{
using namespace rapidjson;
return isValid() ? Value(StringRef(name())) : Value(kNullType);
return isValid() ? Value(StringRef(code())) : Value(kNullType);
}
uint64_t xmrig::Coin::target(uint8_t) const
{
return coinInfo[m_id].target;
}
uint64_t xmrig::Coin::units() const
{
return coinInfo[m_id].units;
}
@@ -124,11 +122,17 @@ xmrig::Coin::Id xmrig::Coin::parse(const char *name)
return INVALID;
}
for (const auto &i : coin_names) {
if (strcasecmp(name, i.name) == 0) {
return i.id;
for (uint32_t i = 1; i < MAX; ++i) {
if (strcasecmp(name, coinInfo[i].code) == 0 || strcasecmp(name, coinInfo[i].name) == 0) {
return static_cast<Id>(i);
}
}
return INVALID;
}
const char *xmrig::Coin::tag(Id id)
{
return coinInfo[id].tag;
}

View File

@@ -1,13 +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 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* 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
@@ -37,38 +30,53 @@ namespace xmrig {
class Coin
{
public:
enum Id : int {
INVALID = -1,
enum Id : uint32_t {
INVALID,
MONERO,
ARQ,
SUMO,
ARQMA,
DERO,
GRAFT,
KEVA,
RAVEN,
CONCEAL,
WOWNERO
WOWNERO,
MAX
};
static const char *kDisabled;
static const char *kField;
static const char *kUnknown;
Coin() = default;
inline Coin(const char *name) : m_id(parse(name)) {}
inline Coin(Id id) : m_id(id) {}
Coin(const rapidjson::Value &value);
inline Coin(const char *name) : m_id(parse(name)) {}
inline Coin(Id id) : m_id(id) {}
inline Coin(uint32_t id) : m_id(id < MAX ? static_cast<Id>(id) : INVALID) {}
inline bool isEqual(const Coin &other) const { return m_id == other.m_id; }
inline bool isValid() const { return m_id != INVALID; }
inline Id id() const { return m_id; }
inline bool isEqual(const Coin &other) const { return m_id == other.m_id; }
inline bool isValid() const { return m_id != INVALID; }
inline Id id() const { return m_id; }
inline const char *tag() const { return tag(m_id); }
inline double decimal(uint64_t amount) const { return static_cast<double>(amount) / units(); }
Algorithm::Id algorithm(uint8_t blobVersion = 255) const;
Algorithm algorithm(uint8_t blobVersion = 255) const;
const char *code() const;
const char *name() const;
rapidjson::Value toJSON() const;
uint64_t target(uint8_t blobVersion = 255) const;
uint64_t units() const;
inline bool operator!=(Coin::Id id) const { return m_id != id; }
inline bool operator!=(const Coin &other) const { return !isEqual(other); }
inline bool operator==(Coin::Id id) const { return m_id == id; }
inline bool operator==(const Coin &other) const { return isEqual(other); }
inline operator Coin::Id() const { return m_id; }
inline bool operator!=(Id id) const { return m_id != id; }
inline bool operator!=(const Coin &other) const { return !isEqual(other); }
inline bool operator<(Id id) const { return m_id < id; }
inline bool operator<(const Coin &other) const { return m_id < other.m_id; }
inline bool operator==(Id id) const { return m_id == id; }
inline bool operator==(const Coin &other) const { return isEqual(other); }
inline operator Id() const { return m_id; }
static Id parse(const char *name);
static const char *tag(Id id);
private:
Id m_id = INVALID;