Fixes for build without cn-lite and cn-heavy.

This commit is contained in:
XMRig 2018-04-12 11:38:43 +07:00
parent a73ad9b089
commit b13640e4a1
8 changed files with 56 additions and 9 deletions

View file

@ -92,7 +92,7 @@ bool xmrig::CommonConfig::adjust()
bool xmrig::CommonConfig::isValid() const bool xmrig::CommonConfig::isValid() const
{ {
return m_pools[0].isValid(); return m_pools[0].isValid() && m_algorithm != INVALID_ALGO;
} }

View file

@ -168,7 +168,7 @@ xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator
} }
if (!config->isValid()) { if (!config->isValid()) {
fprintf(stderr, "No pool URL supplied. Exiting.\n"); fprintf(stderr, "No valid configuration found. Exiting.\n");
delete config; delete config;
return nullptr; return nullptr;
} }
@ -293,13 +293,13 @@ void xmrig::ConfigLoader::showVersion()
printf("\n features:" printf("\n features:"
# if defined(__i386__) || defined(_M_IX86) # if defined(__i386__) || defined(_M_IX86)
" i386" " 32-bit"
# elif defined(__x86_64__) || defined(_M_AMD64) # elif defined(__x86_64__) || defined(_M_AMD64)
" x86_64" " 64-bit"
# endif # endif
# if defined(__AES__) || defined(_MSC_VER) # if defined(__AES__) || defined(_MSC_VER)
" AES-NI" " AES"
# endif # endif
"\n"); "\n");

View file

@ -43,7 +43,17 @@ namespace xmrig {
static char const usage[] = "\ static char const usage[] = "\
Usage: " APP_ID " [OPTIONS]\n\ Usage: " APP_ID " [OPTIONS]\n\
Options:\n\ Options:\n\
-a, --algo=ALGO cryptonight (default) or cryptonight-lite\n\ -a, --algo=ALGO specify the algorithm to use\n\
cryptonight\n"
#ifndef XMRIG_NO_AEON
"\
cryptonight-lite\n"
#endif
#ifndef XMRIG_NO_SUMO
"\
cryptonight-heavy\n"
#endif
"\
-o, --url=URL URL of mining server\n\ -o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\ -u, --user=USERNAME username for mining server\n\

View file

@ -65,6 +65,9 @@ inline size_t cn_select_memory(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MEMORY; return CRYPTONIGHT_HEAVY_MEMORY;
default:
break;
} }
return 0; return 0;
@ -88,6 +91,9 @@ inline uint32_t cn_select_mask(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MASK; return CRYPTONIGHT_HEAVY_MASK;
default:
break;
} }
return 0; return 0;
@ -111,6 +117,9 @@ inline uint32_t cn_select_iter(Algo algorithm)
case CRYPTONIGHT_HEAVY: case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_ITER; return CRYPTONIGHT_HEAVY_ITER;
default:
break;
} }
return 0; return 0;

View file

@ -38,15 +38,31 @@
static const char *algoNames[] = { static const char *algoNames[] = {
"cryptonight", "cryptonight",
# ifndef XMRIG_NO_AEON
"cryptonight-lite", "cryptonight-lite",
# else
nullptr,
# endif
# ifndef XMRIG_NO_SUMO
"cryptonight-heavy" "cryptonight-heavy"
# else
nullptr
# endif
}; };
static const char *algoNamesShort[] = { static const char *algoNamesShort[] = {
"cn", "cn",
# ifndef XMRIG_NO_AEON
"cn-lite", "cn-lite",
# else
nullptr,
# endif
# ifndef XMRIG_NO_SUMO
"cn-heavy" "cn-heavy"
# else
nullptr
# endif
}; };
@ -110,23 +126,26 @@ const char *Pool::algoName(xmrig::Algo algorithm)
xmrig::Algo Pool::algorithm(const char *algo) xmrig::Algo Pool::algorithm(const char *algo)
{ {
# ifndef XMRIG_NO_AEON
if (strcasecmp(algo, "cryptonight-light") == 0) { if (strcasecmp(algo, "cryptonight-light") == 0) {
fprintf(stderr, "Algorithm \"cryptonight-light\" is deprecated, use \"cryptonight-lite\" instead\n"); fprintf(stderr, "Algorithm \"cryptonight-light\" is deprecated, use \"cryptonight-lite\" instead\n");
return xmrig::CRYPTONIGHT_LITE; return xmrig::CRYPTONIGHT_LITE;
} }
# endif
const size_t size = sizeof(algoNames) / sizeof(algoNames[0]); const size_t size = sizeof(algoNames) / sizeof(algoNames[0]);
assert(size == (sizeof(algoNamesShort) / sizeof(algoNamesShort[0]))); assert(size == (sizeof(algoNamesShort) / sizeof(algoNamesShort[0])));
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
if (strcasecmp(algo, algoNames[i]) == 0 || strcasecmp(algo, algoNamesShort[i]) == 0) { if ((algoNames[i] && strcasecmp(algo, algoNames[i]) == 0) || (algoNamesShort[i] && strcasecmp(algo, algoNamesShort[i]) == 0)) {
return static_cast<xmrig::Algo>(i); return static_cast<xmrig::Algo>(i);
} }
} }
return xmrig::CRYPTONIGHT; fprintf(stderr, "Unknown algorithm \"%s\" specified.\n", algo);
return xmrig::INVALID_ALGO;
} }

View file

@ -144,7 +144,11 @@ bool DoubleWorker::selfTest()
} }
# endif # endif
return memcmp(m_hash, test_output_heavy, 64) == 0; # ifndef XMRIG_NO_SUMO
return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && memcmp(m_hash, test_output_heavy, 64) == 0;
# else
return false;
# endif
} }

View file

@ -116,7 +116,11 @@ bool SingleWorker::selfTest()
} }
# endif # endif
# ifndef XMRIG_NO_SUMO
return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && memcmp(m_result.result, test_output_heavy, 32) == 0; return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && memcmp(m_result.result, test_output_heavy, 32) == 0;
# else
return false;
# endif
} }

View file

@ -30,6 +30,7 @@ namespace xmrig
enum Algo { enum Algo {
INVALID_ALGO = -1,
CRYPTONIGHT, /* CryptoNight (Monero) */ CRYPTONIGHT, /* CryptoNight (Monero) */
CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (SUMO) */ CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (SUMO) */