Browse Source

some cleanup and longpoll changes

master
Tanguy Pruvot 10 years ago
parent
commit
5988e945ef
  1. 2
      README.txt
  2. 24
      ccminer.cpp
  3. 1
      miner.h
  4. 2
      util.cpp
  5. 2
      x15/cuda_whirlpoolx.cu

2
README.txt

@ -186,7 +186,7 @@ features.
Mar. 2015 v1.6.0 (Note for CryptoMiningBlog: NOT YET RELEASED/FINISHED!) Mar. 2015 v1.6.0 (Note for CryptoMiningBlog: NOT YET RELEASED/FINISHED!)
Import pluck (djm34) and whirlpoolx (alexis78) algos Import pluck (djm34) and whirlpoolx (alexis78) algos
Hashrate units based on hashing rate values (Hs/kHs/MHs/GHs) 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 Various small fixes
More to come soon... More to come soon...

24
ccminer.cpp

@ -360,9 +360,9 @@ static struct option const options[] = {
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
static struct work _ALIGN(64) g_work; struct work _ALIGN(64) g_work;
static time_t g_work_time; time_t g_work_time;
static pthread_mutex_t g_work_lock; pthread_mutex_t g_work_lock;
#ifdef __linux /* Linux specific policy and affinity management */ #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 (get_blocktemplate(curl, &wheight)) {
if (work->height && work->height < wheight.height) { if (work->height && work->height < wheight.height) {
if (opt_debug) 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; return true;
} }
} }
@ -631,9 +631,8 @@ static bool submit_upstream_work(CURL *curl, struct work *work)
} }
free(noncestr); free(noncestr);
// prevent useless computing on some pools // prevent useless computing on some pools
stratum_need_reset = true; g_work_time = 0;
for (int i = 0; i < opt_n_threads; i++) restart_threads();
work_restart[i].restart = 1;
return true; 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) if (opt_debug && !opt_quiet)
applog(LOG_DEBUG,"%s", __FUNCTION__); applog(LOG_DEBUG,"%s", __FUNCTION__);
@ -1595,7 +1594,7 @@ static void *miner_thread(void *userdata)
// prevent stale work in solo // prevent stale work in solo
// we can't submit twice a block! // we can't submit twice a block!
if (!have_stratum) { if (!have_stratum && !have_longpoll) {
pthread_mutex_lock(&g_work_lock); pthread_mutex_lock(&g_work_lock);
// will force getwork // will force getwork
g_work_time = 0; g_work_time = 0;
@ -1658,7 +1657,7 @@ start:
sprintf(lp_url, "%s%s%s", rpc_url, need_slash ? "/" : "", copy_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) { while (1) {
json_t *val, *soval; json_t *val, *soval;
@ -1672,13 +1671,12 @@ start:
goto out; goto out;
} }
if (likely(val)) { if (likely(val)) {
if (!opt_quiet) applog(LOG_INFO, "LONGPOLL detected new block");
soval = json_object_get(json_object_get(val, "result"), "submitold"); soval = json_object_get(json_object_get(val, "result"), "submitold");
submit_old = soval ? json_is_true(soval) : false; submit_old = soval ? json_is_true(soval) : false;
pthread_mutex_lock(&g_work_lock); pthread_mutex_lock(&g_work_lock);
if (work_decode(json_object_get(val, "result"), &g_work)) { if (work_decode(json_object_get(val, "result"), &g_work)) {
if (opt_debug) if (!opt_quiet)
applog(LOG_BLUE, "LONGPOLL pushed new work"); applog(LOG_BLUE, "%s detected new block", short_url);
g_work_time = time(NULL); g_work_time = time(NULL);
restart_threads(); restart_threads();
} }

1
miner.h

@ -645,6 +645,7 @@ extern void tq_thaw(struct thread_q *tq);
void parse_arg(int key, char *arg); void parse_arg(int key, char *arg);
void proper_exit(int reason); void proper_exit(int reason);
void restart_threads(void);
size_t time2str(char* buf, time_t timer); size_t time2str(char* buf, time_t timer);
char* atime2str(time_t timer); char* atime2str(time_t timer);

2
util.cpp

@ -1344,6 +1344,7 @@ out:
return ret; return ret;
} }
extern time_t g_work_time;
static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params) static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
{ {
double diff; double diff;
@ -1360,6 +1361,7 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
if (diff != global_diff) { if (diff != global_diff) {
global_diff = diff; global_diff = diff;
applog(LOG_WARNING, "Stratum difficulty set to %g", diff); applog(LOG_WARNING, "Stratum difficulty set to %g", diff);
g_work_time = 0;
} }
return true; return true;

2
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) if (thread < threads)
{ {
uint64_t n[8]; uint64_t n[8];
uint64_t h[8] = {0,0,0,0,0,0,0,0}; uint64_t h[8] = { 0 };
#pragma unroll 8 #pragma unroll 8
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {

Loading…
Cancel
Save