Sync changes with proxy.

This commit is contained in:
XMRig 2018-04-30 18:17:07 +07:00
parent 2b0309e159
commit 9c23186172
3 changed files with 33 additions and 28 deletions

View file

@ -123,6 +123,11 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo)
m_algo = INVALID_ALGO;
m_variant = VARIANT_AUTO;
assert(algo != nullptr);
if (algo == nullptr) {
return;
}
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;
@ -182,6 +187,11 @@ void xmrig::Algorithm::parseXmrStakAlgorithm(const char *algo)
m_algo = INVALID_ALGO;
m_variant = VARIANT_AUTO;
assert(algo != nullptr);
if (algo == nullptr) {
return;
}
for (size_t i = 0; i < ARRAY_SIZE(xmrStakAlgorithms); i++) {
if (strcasecmp(algo, xmrStakAlgorithms[i].name) == 0) {
m_algo = xmrStakAlgorithms[i].algo;

View file

@ -37,9 +37,6 @@
#endif
#define ADD_VARIANT(variant) m_algorithms.push_back(xmrig::Algorithm(m_algorithm.algo(), variant));
#ifdef _MSC_VER
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
@ -240,32 +237,15 @@ void Pool::adjust(xmrig::Algo algorithm)
m_algorithm.setVariant(xmrig::VARIANT_1);
}
# ifndef XMRIG_PROXY_PROJECT
switch (m_algorithm.algo()) {
case xmrig::CRYPTONIGHT:
ADD_VARIANT(xmrig::VARIANT_AUTO);
ADD_VARIANT(xmrig::VARIANT_0);
ADD_VARIANT(xmrig::VARIANT_1);
ADD_VARIANT(xmrig::VARIANT_XTL);
break;
case xmrig::CRYPTONIGHT_LITE:
ADD_VARIANT(xmrig::VARIANT_AUTO);
ADD_VARIANT(xmrig::VARIANT_0);
ADD_VARIANT(xmrig::VARIANT_1);
ADD_VARIANT(xmrig::VARIANT_IPBC);
break;
case xmrig::CRYPTONIGHT_HEAVY:
ADD_VARIANT(xmrig::VARIANT_0);
break;
default:
break;
}
# else
m_algorithms.push_back(m_algorithm);
# endif
if (m_algorithm.algo() != xmrig::CRYPTONIGHT_HEAVY) {
addVariant(xmrig::VARIANT_1);
addVariant(xmrig::VARIANT_0);
addVariant(xmrig::VARIANT_XTL);
addVariant(xmrig::VARIANT_IPBC);
addVariant(xmrig::VARIANT_AUTO);
}
}
@ -306,3 +286,14 @@ bool Pool::parseIPv6(const char *addr)
return true;
}
void Pool::addVariant(xmrig::Variant variant)
{
const xmrig::Algorithm algorithm(m_algorithm.algo(), variant);
if (!algorithm.isValid() || m_algorithm == algorithm) {
return;
}
m_algorithms.push_back(algorithm);
}

View file

@ -85,6 +85,7 @@ public:
private:
bool parseIPv6(const char *addr);
void addVariant(xmrig::Variant variant);
bool m_nicehash;
int m_keepAlive;
@ -98,4 +99,7 @@ private:
xmrig::c_str m_user;
};
typedef std::vector<Pool> Pools;
#endif /* __POOL_H__ */