Update Coin, BlobReader and WalletAddress.

This commit is contained in:
XMRig 2021-08-17 08:17:21 +07:00
parent 9eac9dd30a
commit d1033abbe5
No known key found for this signature in database
GPG key ID: 446A53638BE94409
8 changed files with 369 additions and 165 deletions

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,52 @@ namespace xmrig {
class Coin
{
public:
enum Id : int {
INVALID = -1,
enum Id : uint32_t {
INVALID,
MONERO,
SUMO,
ARQMA,
DERO,
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;