diff --git a/src/core/CommonConfig.cpp b/src/core/CommonConfig.cpp index b1758921a..b444537e6 100644 --- a/src/core/CommonConfig.cpp +++ b/src/core/CommonConfig.cpp @@ -92,7 +92,7 @@ bool xmrig::CommonConfig::adjust() bool xmrig::CommonConfig::isValid() const { - return m_pools[0].isValid(); + return m_pools[0].isValid() && m_algorithm != INVALID_ALGO; } diff --git a/src/core/ConfigLoader.cpp b/src/core/ConfigLoader.cpp index 8c7f6546a..c84ba962d 100644 --- a/src/core/ConfigLoader.cpp +++ b/src/core/ConfigLoader.cpp @@ -168,7 +168,7 @@ xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator } if (!config->isValid()) { - fprintf(stderr, "No pool URL supplied. Exiting.\n"); + fprintf(stderr, "No valid configuration found. Exiting.\n"); delete config; return nullptr; } @@ -293,13 +293,13 @@ void xmrig::ConfigLoader::showVersion() printf("\n features:" # if defined(__i386__) || defined(_M_IX86) - " i386" + " 32-bit" # elif defined(__x86_64__) || defined(_M_AMD64) - " x86_64" + " 64-bit" # endif # if defined(__AES__) || defined(_MSC_VER) - " AES-NI" + " AES" # endif "\n"); diff --git a/src/core/ConfigLoader_platform.h b/src/core/ConfigLoader_platform.h index 68eef6399..a090fb99d 100644 --- a/src/core/ConfigLoader_platform.h +++ b/src/core/ConfigLoader_platform.h @@ -43,7 +43,17 @@ namespace xmrig { static char const usage[] = "\ Usage: " APP_ID " [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, --userpass=U:P username:password pair for mining server\n\ -u, --user=USERNAME username for mining server\n\ diff --git a/src/crypto/CryptoNight_constants.h b/src/crypto/CryptoNight_constants.h index d576b47a7..60f0df087 100644 --- a/src/crypto/CryptoNight_constants.h +++ b/src/crypto/CryptoNight_constants.h @@ -65,6 +65,9 @@ inline size_t cn_select_memory(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MEMORY; + + default: + break; } return 0; @@ -88,6 +91,9 @@ inline uint32_t cn_select_mask(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MASK; + + default: + break; } return 0; @@ -111,6 +117,9 @@ inline uint32_t cn_select_iter(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_ITER; + + default: + break; } return 0; diff --git a/src/net/Pool.cpp b/src/net/Pool.cpp index b3766b08c..4d1d74391 100644 --- a/src/net/Pool.cpp +++ b/src/net/Pool.cpp @@ -38,15 +38,31 @@ static const char *algoNames[] = { "cryptonight", +# ifndef XMRIG_NO_AEON "cryptonight-lite", +# else + nullptr, +# endif +# ifndef XMRIG_NO_SUMO "cryptonight-heavy" +# else + nullptr +# endif }; static const char *algoNamesShort[] = { "cn", +# ifndef XMRIG_NO_AEON "cn-lite", +# else + nullptr, +# endif +# ifndef XMRIG_NO_SUMO "cn-heavy" +# else + nullptr +# endif }; @@ -110,23 +126,26 @@ const char *Pool::algoName(xmrig::Algo algorithm) xmrig::Algo Pool::algorithm(const char *algo) { +# ifndef XMRIG_NO_AEON if (strcasecmp(algo, "cryptonight-light") == 0) { fprintf(stderr, "Algorithm \"cryptonight-light\" is deprecated, use \"cryptonight-lite\" instead\n"); return xmrig::CRYPTONIGHT_LITE; } +# endif const size_t size = sizeof(algoNames) / sizeof(algoNames[0]); assert(size == (sizeof(algoNamesShort) / sizeof(algoNamesShort[0]))); 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(i); } } - return xmrig::CRYPTONIGHT; + fprintf(stderr, "Unknown algorithm \"%s\" specified.\n", algo); + return xmrig::INVALID_ALGO; } diff --git a/src/workers/DoubleWorker.cpp b/src/workers/DoubleWorker.cpp index a61767431..6ba5c47fe 100644 --- a/src/workers/DoubleWorker.cpp +++ b/src/workers/DoubleWorker.cpp @@ -144,7 +144,11 @@ bool DoubleWorker::selfTest() } # 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 } diff --git a/src/workers/SingleWorker.cpp b/src/workers/SingleWorker.cpp index ca6b93a6c..815b965dd 100644 --- a/src/workers/SingleWorker.cpp +++ b/src/workers/SingleWorker.cpp @@ -116,7 +116,11 @@ bool SingleWorker::selfTest() } # endif +# ifndef XMRIG_NO_SUMO return m_thread->algorithm() == xmrig::CRYPTONIGHT_HEAVY && memcmp(m_result.result, test_output_heavy, 32) == 0; +# else + return false; +# endif } diff --git a/src/xmrig.h b/src/xmrig.h index f4ae81620..7196aee3f 100644 --- a/src/xmrig.h +++ b/src/xmrig.h @@ -30,6 +30,7 @@ namespace xmrig enum Algo { + INVALID_ALGO = -1, CRYPTONIGHT, /* CryptoNight (Monero) */ CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (SUMO) */