diff --git a/CHANGELOG.md b/CHANGELOG.md index c67b8a20..bcaf27c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # v2.6.0-beta2 - [#499](https://github.com/xmrig/xmrig/issues/499) IPv6 disabled for internal HTTP API by default, was cause issues on some systems. +- Added short aliases for algorithm names: `cn`, `cn-lite` and `cn-heavy`. - Fixed regressions (v2.6.0-beta1 affected) - [#494](https://github.com/xmrig/xmrig/issues/494) Command line option `--donate-level` was broken. - [#502](https://github.com/xmrig/xmrig/issues/502) Build without libmicrohttpd was broken. diff --git a/src/core/CommonConfig.cpp b/src/core/CommonConfig.cpp index 8d2eb03a..8950775c 100644 --- a/src/core/CommonConfig.cpp +++ b/src/core/CommonConfig.cpp @@ -22,6 +22,7 @@ */ +#include #include #include #include @@ -45,6 +46,13 @@ static const char *algoNames[] = { }; +static const char *algoNamesShort[] = { + "cn", + "cn-lite", + "cn-heavy" +}; + + #if defined(_WIN32) && !defined(strcasecmp) # define strcasecmp _stricmp #endif @@ -375,12 +383,21 @@ void xmrig::CommonConfig::setAlgo(const char *algo) return; } - 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]))); for (size_t i = 0; i < size; i++) { if (algoNames[i] && strcasecmp(algo, algoNames[i]) == 0) { m_algorithm = static_cast(i); - break; + return; + } + } + + for (size_t i = 0; i < size; i++) { + if (algoNamesShort[i] && strcasecmp(algo, algoNamesShort[i]) == 0) { + m_algorithm = static_cast(i); + return; } } }