Better v1 PoW implementation, added variant option.

This commit is contained in:
XMRig 2018-03-12 22:29:44 +07:00
parent 83e5832bc1
commit aec31c43c0
19 changed files with 236 additions and 116 deletions

View file

@ -47,6 +47,7 @@
#include "rapidjson/error/en.h"
#include "rapidjson/filereadstream.h"
#include "version.h"
#include "xmrig.h"
#ifndef ARRAY_SIZE
@ -74,7 +75,7 @@ Options:\n\
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
--no-huge-pages disable huge pages support\n\
--no-color disable colored output\n\
--no-monero disable Monero v7 PoW\n\
--variant algorithm PoW variant\n\
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
--user-agent set custom user-agent string for pool\n\
-B, --background run the miner in the background\n\
@ -119,7 +120,7 @@ static struct option const options[] = {
{ "nicehash", 0, nullptr, 1006 },
{ "no-color", 0, nullptr, 1002 },
{ "no-huge-pages", 0, nullptr, 1009 },
{ "no-monero", 0, nullptr, 1010 },
{ "variant", 1, nullptr, 1010 },
{ "pass", 1, nullptr, 'p' },
{ "print-time", 1, nullptr, 1007 },
{ "retries", 1, nullptr, 'r' },
@ -160,12 +161,12 @@ static struct option const config_options[] = {
static struct option const pool_options[] = {
{ "pass", 1, nullptr, 'p' },
{ "url", 1, nullptr, 'o' },
{ "pass", 1, nullptr, 'p' },
{ "user", 1, nullptr, 'u' },
{ "userpass", 1, nullptr, 'O' },
{ "keepalive", 0, nullptr ,'k' },
{ "monero", 0, nullptr, 1010 },
{ "variant", 1, nullptr, 1010 },
{ "nicehash", 0, nullptr, 1006 },
{ 0, 0, 0, 0 }
};
@ -275,9 +276,7 @@ Options::Options(int argc, char **argv) :
}
}
for (Url *url : m_pools) {
url->applyExceptions();
}
adjust();
m_ready = true;
}
@ -383,6 +382,7 @@ bool Options::parseArg(int key, const char *arg)
case 1007: /* --print-time */
case 1021: /* --cpu-priority */
case 4000: /* --api-port */
case 1010: /* --variant */
return parseArg(key, strtol(arg, nullptr, 10));
case 'B': /* --background */
@ -395,7 +395,6 @@ bool Options::parseArg(int key, const char *arg)
case 1002: /* --no-color */
case 1009: /* --no-huge-pages */
case 1010: /* --no-monero */
return parseBoolean(key, false);
case 't': /* --threads */
@ -502,6 +501,10 @@ bool Options::parseArg(int key, uint64_t arg)
m_printTime = (int) arg;
break;
case 1010: /* --variant */
m_pools.back()->setVariant((int) arg);
break;
case 1020: /* --cpu-affinity */
if (arg) {
m_affinity = arg;
@ -561,10 +564,6 @@ bool Options::parseBoolean(int key, bool enable)
m_hugePages = enable;
break;
case 1010: /* monero */
m_pools.back()->setMonero(enable);
break;
case 2000: /* colors */
m_colors = enable;
break;
@ -593,6 +592,14 @@ Url *Options::parseUrl(const char *arg) const
}
void Options::adjust()
{
for (Url *url : m_pools) {
url->adjust(m_algo);
}
}
void Options::parseConfig(const char *fileName)
{
rapidjson::Document doc;
@ -637,7 +644,7 @@ void Options::parseJSON(const struct option *option, const rapidjson::Value &obj
if (option->has_arg && value.IsString()) {
parseArg(option->val, value.GetString());
}
else if (option->has_arg && value.IsUint64()) {
else if (option->has_arg && value.IsInt64()) {
parseArg(option->val, value.GetUint64());
}
else if (!option->has_arg && value.IsBool()) {
@ -703,7 +710,7 @@ bool Options::setAlgo(const char *algo)
# ifndef XMRIG_NO_AEON
if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light")) {
m_algo = ALGO_CRYPTONIGHT_LITE;
m_algo = xmrig::ALGO_CRYPTONIGHT_LITE;
break;
}
# endif
@ -721,7 +728,7 @@ bool Options::setAlgo(const char *algo)
int Options::getAlgoVariant() const
{
# ifndef XMRIG_NO_AEON
if (m_algo == ALGO_CRYPTONIGHT_LITE) {
if (m_algo == xmrig::ALGO_CRYPTONIGHT_LITE) {
return getAlgoVariantLite();
}
# endif