From 5988e945ef8796b61622c875c4e1c5040355d50b Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 27 Mar 2015 07:46:19 +0100 Subject: [PATCH] some cleanup and longpoll changes --- README.txt | 2 +- ccminer.cpp | 24 +++++++++++------------- miner.h | 1 + util.cpp | 2 ++ x15/cuda_whirlpoolx.cu | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.txt b/README.txt index 5e5dd24..8d4e17a 100644 --- a/README.txt +++ b/README.txt @@ -186,7 +186,7 @@ features. Mar. 2015 v1.6.0 (Note for CryptoMiningBlog: NOT YET RELEASED/FINISHED!) Import pluck (djm34) and whirlpoolx (alexis78) algos Hashrate units based on hashing rate values (Hs/kHs/MHs/GHs) - Default config file (also help to debug without command line) + Default config file (also help to debug without command line) Various small fixes More to come soon... diff --git a/ccminer.cpp b/ccminer.cpp index 97934cd..87c016d 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -360,9 +360,9 @@ static struct option const options[] = { { 0, 0, 0, 0 } }; -static struct work _ALIGN(64) g_work; -static time_t g_work_time; -static pthread_mutex_t g_work_lock; +struct work _ALIGN(64) g_work; +time_t g_work_time; +pthread_mutex_t g_work_lock; #ifdef __linux /* Linux specific policy and affinity management */ @@ -597,7 +597,7 @@ static bool submit_upstream_work(CURL *curl, struct work *work) if (get_blocktemplate(curl, &wheight)) { if (work->height && work->height < wheight.height) { if (opt_debug) - applog(LOG_WARNING, "bloc %u was already solved", work->height, wheight.height); + applog(LOG_WARNING, "bloc %u was already solved", work->height); return true; } } @@ -631,9 +631,8 @@ static bool submit_upstream_work(CURL *curl, struct work *work) } free(noncestr); // prevent useless computing on some pools - stratum_need_reset = true; - for (int i = 0; i < opt_n_threads; i++) - work_restart[i].restart = 1; + g_work_time = 0; + restart_threads(); return true; } @@ -1148,7 +1147,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) } } -static void restart_threads(void) +void restart_threads(void) { if (opt_debug && !opt_quiet) applog(LOG_DEBUG,"%s", __FUNCTION__); @@ -1595,7 +1594,7 @@ static void *miner_thread(void *userdata) // prevent stale work in solo // we can't submit twice a block! - if (!have_stratum) { + if (!have_stratum && !have_longpoll) { pthread_mutex_lock(&g_work_lock); // will force getwork g_work_time = 0; @@ -1658,7 +1657,7 @@ start: sprintf(lp_url, "%s%s%s", rpc_url, need_slash ? "/" : "", copy_start); } - applog(LOG_INFO, "Long-polling activated for %s", lp_url); + applog(LOG_INFO, "Long-polling enabled on %s", lp_url); while (1) { json_t *val, *soval; @@ -1672,13 +1671,12 @@ start: goto out; } if (likely(val)) { - if (!opt_quiet) applog(LOG_INFO, "LONGPOLL detected new block"); soval = json_object_get(json_object_get(val, "result"), "submitold"); submit_old = soval ? json_is_true(soval) : false; pthread_mutex_lock(&g_work_lock); if (work_decode(json_object_get(val, "result"), &g_work)) { - if (opt_debug) - applog(LOG_BLUE, "LONGPOLL pushed new work"); + if (!opt_quiet) + applog(LOG_BLUE, "%s detected new block", short_url); g_work_time = time(NULL); restart_threads(); } diff --git a/miner.h b/miner.h index 0944e59..6483b15 100644 --- a/miner.h +++ b/miner.h @@ -645,6 +645,7 @@ extern void tq_thaw(struct thread_q *tq); void parse_arg(int key, char *arg); void proper_exit(int reason); +void restart_threads(void); size_t time2str(char* buf, time_t timer); char* atime2str(time_t timer); diff --git a/util.cpp b/util.cpp index 00b8f08..59f5e9d 100644 --- a/util.cpp +++ b/util.cpp @@ -1344,6 +1344,7 @@ out: return ret; } +extern time_t g_work_time; static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params) { double diff; @@ -1360,6 +1361,7 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params) if (diff != global_diff) { global_diff = diff; applog(LOG_WARNING, "Stratum difficulty set to %g", diff); + g_work_time = 0; } return true; diff --git a/x15/cuda_whirlpoolx.cu b/x15/cuda_whirlpoolx.cu index f772a7f..129a1f9 100644 --- a/x15/cuda_whirlpoolx.cu +++ b/x15/cuda_whirlpoolx.cu @@ -181,7 +181,7 @@ void whirlpoolx_gpu_precompute(uint32_t threads, uint64_t* d_xtra, uint64_t* d_t if (thread < threads) { uint64_t n[8]; - uint64_t h[8] = {0,0,0,0,0,0,0,0}; + uint64_t h[8] = { 0 }; #pragma unroll 8 for (int i=0; i<8; i++) {