Allow ignore block version.

This commit is contained in:
XMRig 2019-01-14 20:59:39 +07:00
parent 492449e9fb
commit eede1b4881
3 changed files with 43 additions and 13 deletions

View file

@ -150,10 +150,16 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
m_variant = VARIANT_AUTO; m_variant = VARIANT_AUTO;
assert(algo != nullptr); assert(algo != nullptr);
if (algo == nullptr) { if (algo == nullptr || strlen(algo) < 1) {
return; return;
} }
if (*algo == '!') {
m_flags |= Forced;
return parseAlgorithm(algo + 1);
}
for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) { for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) {
if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) { if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) {
m_algo = algorithms[i].algo; m_algo = algorithms[i].algo;
@ -172,6 +178,16 @@ void xmrig::Algorithm::parseVariant(const char *variant)
{ {
m_variant = VARIANT_AUTO; m_variant = VARIANT_AUTO;
if (variant == nullptr || strlen(variant) < 1) {
return;
}
if (*variant == '!') {
m_flags |= Forced;
return parseVariant(variant + 1);
}
for (size_t i = 0; i < ARRAY_SIZE(variants); i++) { for (size_t i = 0; i < ARRAY_SIZE(variants); i++) {
if (strcasecmp(variant, variants[i]) == 0) { if (strcasecmp(variant, variants[i]) == 0) {
m_variant = static_cast<Variant>(i); m_variant = static_cast<Variant>(i);

View file

@ -39,28 +39,38 @@ namespace xmrig {
class Algorithm class Algorithm
{ {
public: public:
enum Flags {
None = 0,
Forced = 1
};
inline Algorithm() : inline Algorithm() :
m_algo(INVALID_ALGO), m_algo(INVALID_ALGO),
m_flags(0),
m_variant(VARIANT_AUTO) m_variant(VARIANT_AUTO)
{} {}
inline Algorithm(Algo algo, Variant variant) : inline Algorithm(Algo algo, Variant variant) :
m_flags(0),
m_variant(variant) m_variant(variant)
{ {
setAlgo(algo); setAlgo(algo);
} }
inline Algorithm(const char *algo) inline Algorithm(const char *algo) :
m_flags(0)
{ {
parseAlgorithm(algo); parseAlgorithm(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 Algo algo() const { return m_algo; } inline bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; }
inline const char *name() const { return name(false); } inline bool isForced() const { return m_flags & Forced; }
inline const char *shortName() const { return name(true); } inline const char *name() const { return name(false); }
inline Variant variant() const { return m_variant; } inline const char *shortName() const { return name(true); }
inline void setVariant(Variant variant) { m_variant = variant; } inline int flags() const { return m_flags; }
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); }
inline bool operator==(const Algorithm &other) const { return isEqual(other); } inline bool operator==(const Algorithm &other) const { return isEqual(other); }
@ -80,6 +90,7 @@ private:
const char *name(bool shortName) const; const char *name(bool shortName) const;
Algo m_algo; Algo m_algo;
int m_flags;
Variant m_variant; Variant m_variant;
}; };

View file

@ -124,11 +124,14 @@ bool Job::setBlob(const char *blob)
if (m_autoVariant) { if (m_autoVariant) {
m_algorithm.setVariant(variant()); m_algorithm.setVariant(variant());
} }
else if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
m_algorithm.setVariant(xmrig::VARIANT_HALF); if (!m_algorithm.isForced()) {
} if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) { m_algorithm.setVariant(xmrig::VARIANT_HALF);
m_algorithm.setVariant(xmrig::VARIANT_HALF); }
else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) {
m_algorithm.setVariant(xmrig::VARIANT_HALF);
}
} }
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT