Merge branch 'dev'

This commit is contained in:
XMRig 2017-05-20 23:53:16 +03:00
commit b145f14ad8
8 changed files with 60 additions and 11 deletions

View file

@ -1,3 +1,6 @@
# v0.8.1
- Added nicehash support, detects automaticaly by pool URL, for example `cryptonight.eu.nicehash.com:3355` or manually via option `--nicehash`.
# v0.8.0
- Added double hash mode, also known as lower power mode. `--av=2` and `--av=4`.
- Added smart automatic CPU configuration. Default threads count now depends on size of the L3 cache of CPU.

View file

@ -24,6 +24,7 @@ Based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of
* Command line options compatible with cpuminer.
* CryptoNight-Lite support for AEON.
* Smart automatic [CPU configuration](https://github.com/xmrig/xmrig/wiki/Threads).
* Nicehash support
* It's open source software.
## Download
@ -57,6 +58,7 @@ xmrig.exe -o xmr-eu.dwarfpool.com:8005 -u YOUR_WALLET -p x -k
-c, --config=FILE load a JSON-format configuration file
--max-cpu-usage=N maximum cpu usage for automatic threads mode (default 75)
--safe safe adjust threads and av settings for current cpu
--nicehash enable nicehash support
-h, --help display this help and exit
-V, --version output version information and exit
```

View file

@ -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;
@ -78,6 +79,7 @@ Options:\n\
-c, --config=FILE load a JSON-format configuration file\n\
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
--safe safe adjust threads and av settings for current CPU\n\
--nicehash enable nicehash support\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
";
@ -97,6 +99,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 +334,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);
}
@ -435,6 +442,10 @@ void parse_cmdline(int argc, char *argv[]) {
proper_exit(1);
}
if (strstr(opt_url, ".nicehash.com:") != NULL) {
opt_nicehash = true;
}
if (!opt_userpass) {
opt_userpass = malloc(strlen(opt_user) + strlen(opt_pass) + 2);
if (!opt_userpass) {

View file

@ -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;

View file

@ -238,8 +238,14 @@ bool stratum_handle_response(char *buf) {
json_t *id_val = json_object_get(val, "id");
if (!id_val || json_is_null(id_val) || !res_val) {
json_decref(val);
return false;
const char* message;
if (json_is_object(err_val) && (message = json_string_value(json_object_get(err_val, "message")))) {
applog(LOG_ERR, "error: \"%s\"", message);
}
json_decref(val);
return false;
}
json_t *status = json_object_get(res_val, "status");
@ -288,7 +294,6 @@ bool stratum_keepalived(struct stratum_ctx *sctx)
bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *pass)
{
char *sret;
json_error_t err;
char *req = malloc(128 + strlen(user) + strlen(pass));
sprintf(req, "{\"method\":\"login\",\"params\":{\"login\":\"%s\",\"pass\":\"%s\",\"agent\":\"%s/%s\"},\"id\":1}", user, pass, APP_NAME, APP_VERSION);
@ -324,7 +329,15 @@ bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *p
json_t *error = json_object_get(val, "error");
if (!result || json_is_false(result) || (error && !json_is_null(error))) {
applog(LOG_ERR, "Stratum authentication failed");
const char* message;
if (json_is_object(error) && (message = json_string_value(json_object_get(error, "message")))) {
applog(LOG_ERR, "Stratum authentication failed: \"%s\"", message);
}
else {
applog(LOG_ERR, "Stratum authentication failed");
}
json_decref(val);
return false;
}

View file

@ -71,11 +71,16 @@ static void print_cpu() {
static void print_threads() {
const char *extra = "";
if (opt_nicehash) {
extra = ", nicehash";
}
if (opt_colors) {
applog_notime(LOG_INFO, CL_LGR " * " CL_WHT "THREADS: " CL_WHT "%d" CL_WHT ", av=%d, %s, donate=%d%%", opt_n_threads, opt_algo_variant, get_current_algo_name(), opt_donate_level);
applog_notime(LOG_INFO, CL_LGR " * " CL_WHT "THREADS: " CL_WHT "%d" CL_WHT ", av=%d, %s, donate=%d%%%s", opt_n_threads, opt_algo_variant, get_current_algo_name(), opt_donate_level, extra);
}
else {
applog_notime(LOG_INFO, " * THREADS: %d, av=%d, %s, donate=%d%%", opt_n_threads, opt_algo_variant, get_current_algo_name(), opt_donate_level);
applog_notime(LOG_INFO, " * THREADS: %d, av=%d, %s, donate=%d%%%s", opt_n_threads, opt_algo_variant, get_current_algo_name(), opt_donate_level, extra);
}
}

View file

@ -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__ */

20
xmrig.c
View file

@ -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);