From 2baccab0f910a53efb8c9b2f0c6db45a5cb290c3 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 20 May 2017 07:08:41 +0300 Subject: [PATCH] Initial test nicehash support. --- options.c | 6 ++++++ options.h | 1 + version.h | 4 ++-- xmrig.c | 20 +++++++++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/options.c b/options.c index b13a579c9..9322f27d6 100644 --- a/options.c +++ b/options.c @@ -48,6 +48,7 @@ bool opt_keepalive = false; bool opt_background = false; bool opt_double_hash = false; bool opt_safe = false; +bool opt_nicehash = false; char *opt_url = NULL; char *opt_backup_url = NULL; char *opt_userpass = NULL; @@ -97,6 +98,7 @@ static struct option const options[] = { { "help", 0, NULL, 'h' }, { "keepalive", 0, NULL ,'k' }, { "max-cpu-usage", 1, NULL, 1004 }, + { "nicehash", 0, NULL, 1006 }, { "no-color", 0, NULL, 1002 }, { "pass", 1, NULL, 'p' }, { "retries", 1, NULL, 'r' }, @@ -331,6 +333,10 @@ static void parse_arg(int key, char *arg) { opt_donate_level = v; break; + case 1006: /* --nicehash */ + opt_nicehash = true; + break; + default: show_usage_and_exit(1); } diff --git a/options.h b/options.h index 2cc419158..a14aaeeb4 100644 --- a/options.h +++ b/options.h @@ -65,6 +65,7 @@ extern bool opt_keepalive; extern bool opt_background; extern bool opt_double_hash; extern bool opt_safe; +extern bool opt_nicehash; extern char *opt_url; extern char *opt_backup_url; extern char *opt_userpass; diff --git a/version.h b/version.h index 301e3f453..8804e2713 100644 --- a/version.h +++ b/version.h @@ -27,14 +27,14 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "Monero (XMR) CPU miner" -#define APP_VERSION "0.8.0" +#define APP_VERSION "0.8.1" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" #define APP_VER_MAJOR 0 #define APP_VER_MINOR 8 -#define APP_VER_BUILD 0 +#define APP_VER_BUILD 1 #define APP_VER_REV 0 #endif /* __VERSION_H__ */ diff --git a/xmrig.c b/xmrig.c index 5aeb04c5c..d3c423a50 100644 --- a/xmrig.c +++ b/xmrig.c @@ -280,7 +280,14 @@ static void *miner_thread(void *userdata) { if (memcmp(work.job_id, stratum_ctx->g_work.job_id, 64)) { work_copy(&work, &stratum_ctx->g_work); nonceptr = (uint32_t*) (((char*) work.blob) + 39); - *nonceptr = 0xffffffffU / opt_n_threads * thr_id; + + if (opt_nicehash) { + end_nonce = (*nonceptr & 0xff000000U) + (0xffffffU / opt_n_threads * (thr_id + 1) - 0x20); + *nonceptr = (*nonceptr & 0xff000000U) + (0xffffffU / opt_n_threads * thr_id); + } + else { + *nonceptr = 0xffffffffU / opt_n_threads * thr_id; + } } pthread_mutex_unlock(&stratum_ctx->work_lock); @@ -356,8 +363,15 @@ static void *miner_thread_double(void *userdata) { nonceptr0 = (uint32_t*) (((char*) double_blob) + 39); nonceptr1 = (uint32_t*) (((char*) double_blob) + 39 + work.blob_size); - *nonceptr0 = 0xffffffffU / (opt_n_threads * 2) * thr_id; - *nonceptr1 = 0xffffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads); + if (opt_nicehash) { + end_nonce = (*nonceptr0 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * (thr_id + 1) - 0x20); + *nonceptr0 = (*nonceptr0 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * thr_id); + *nonceptr1 = (*nonceptr1 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads)); + } + else { + *nonceptr0 = 0xffffffffU / (opt_n_threads * 2) * thr_id; + *nonceptr1 = 0xffffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads); + } } pthread_mutex_unlock(&stratum_ctx->work_lock);