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;
assert(algo != nullptr);
if (algo == nullptr) {
if (algo == nullptr || strlen(algo) < 1) {
return;
}
if (*algo == '!') {
m_flags |= Forced;
return parseAlgorithm(algo + 1);
}
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;
@ -172,6 +178,16 @@ void xmrig::Algorithm::parseVariant(const char *variant)
{
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++) {
if (strcasecmp(variant, variants[i]) == 0) {
m_variant = static_cast<Variant>(i);

View file

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

View file

@ -124,12 +124,15 @@ bool Job::setBlob(const char *blob)
if (m_autoVariant) {
m_algorithm.setVariant(variant());
}
else if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
if (!m_algorithm.isForced()) {
if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) {
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
memset(m_rawBlob, 0, sizeof(m_rawBlob));