Browse Source

stratum: check stratum_gen_work result

and remove useless purge test...
master
Tanguy Pruvot 10 years ago
parent
commit
b2b76f8006
  1. 20
      ccminer.cpp

20
ccminer.cpp

@ -465,7 +465,7 @@ struct opt_config_array {
}; };
struct work _ALIGN(64) g_work; struct work _ALIGN(64) g_work;
time_t g_work_time; volatile time_t g_work_time;
pthread_mutex_t g_work_lock; pthread_mutex_t g_work_lock;
@ -759,6 +759,7 @@ static int share_result(int result, int pooln, const char *reason)
if (!check_dups && strncasecmp(reason, "duplicate", 9) == 0) { if (!check_dups && strncasecmp(reason, "duplicate", 9) == 0) {
applog(LOG_WARNING, "enabling duplicates check feature"); applog(LOG_WARNING, "enabling duplicates check feature");
check_dups = true; check_dups = true;
g_work_time = 0;
} }
} }
return 1; return 1;
@ -1303,14 +1304,14 @@ err_out:
return false; return false;
} }
static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
{ {
uchar merkle_root[64]; uchar merkle_root[64];
int i; int i;
if (!sctx->job.job_id) { if (!sctx->job.job_id) {
// applog(LOG_WARNING, "stratum_gen_work: job not yet retrieved"); // applog(LOG_WARNING, "stratum_gen_work: job not yet retrieved");
return; return false;
} }
pthread_mutex_lock(&stratum_work_lock); pthread_mutex_lock(&stratum_work_lock);
@ -1425,6 +1426,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
default: default:
diff_to_target(work->target, sctx->job.diff / opt_difficulty); diff_to_target(work->target, sctx->job.diff / opt_difficulty);
} }
return true;
} }
void restart_threads(void) void restart_threads(void)
@ -1567,7 +1569,8 @@ static void *miner_thread(void *userdata)
if (nonceptr[0] >= end_nonce || extrajob) { if (nonceptr[0] >= end_nonce || extrajob) {
work_done = false; work_done = false;
extrajob = false; extrajob = false;
stratum_gen_work(&stratum, &g_work); if (stratum_gen_work(&stratum, &g_work))
g_work_time = time(NULL);
} }
} else { } else {
pthread_mutex_lock(&g_work_lock); pthread_mutex_lock(&g_work_lock);
@ -1596,11 +1599,6 @@ static void *miner_thread(void *userdata)
work.difficulty = g_work.difficulty; work.difficulty = g_work.difficulty;
work.height = g_work.height; work.height = g_work.height;
nonceptr[0] = (UINT32_MAX / opt_n_threads) * thr_id; // 0 if single thr nonceptr[0] = (UINT32_MAX / opt_n_threads) * thr_id; // 0 if single thr
/* on new target, ignoring nonce, clear sent data (hashlog) */
if (memcmp(work.target, g_work.target, sizeof(work.target))) {
if (check_dups)
hashlog_purge_job(work.job_id);
}
} }
if (opt_algo == ALGO_ZR5) { if (opt_algo == ALGO_ZR5) {
@ -2284,8 +2282,8 @@ wait_stratum_url:
if (stratum.job.job_id && if (stratum.job.job_id &&
(!g_work_time || strncmp(stratum.job.job_id, g_work.job_id + 8, 120))) { (!g_work_time || strncmp(stratum.job.job_id, g_work.job_id + 8, 120))) {
pthread_mutex_lock(&g_work_lock); pthread_mutex_lock(&g_work_lock);
stratum_gen_work(&stratum, &g_work); if (stratum_gen_work(&stratum, &g_work))
g_work_time = time(NULL); g_work_time = time(NULL);
if (stratum.job.clean) { if (stratum.job.clean) {
if (!opt_quiet) { if (!opt_quiet) {
if (net_diff > 0.) if (net_diff > 0.)

Loading…
Cancel
Save