Skip to content

Commit d0881e8

Browse files
committed
store the next difficulty
1 parent 666641b commit d0881e8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

miner.h

+1
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,7 @@ struct pool {
13911391
unsigned char *coinbase;
13921392
size_t nonce2_offset;
13931393
unsigned char header_bin[128];
1394+
double next_diff;
13941395
int merkle_offset;
13951396

13961397
struct timeval tv_lastwork;

util.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
15601560
pool->swork.nbit = nbit;
15611561
pool->swork.ntime = ntime;
15621562
pool->swork.clean = clean;
1563+
pool->swork.diff = pool->next_diff;
15631564
alloc_len = pool->swork.cb_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;
15641565
pool->nonce2_offset = cb1_len + pool->n1_len;
15651566

@@ -1668,8 +1669,8 @@ static bool parse_diff(struct pool *pool, json_t *val)
16681669
return false;
16691670

16701671
cg_wlock(&pool->data_lock);
1671-
old_diff = pool->swork.diff;
1672-
pool->swork.diff = diff;
1672+
old_diff = pool->next_diff;
1673+
pool->next_diff = diff;
16731674
cg_wunlock(&pool->data_lock);
16741675

16751676
if (old_diff != diff) {
@@ -2560,7 +2561,7 @@ bool initiate_stratum(struct pool *pool)
25602561
if (!pool->stratum_url)
25612562
pool->stratum_url = pool->sockaddr_url;
25622563
pool->stratum_active = true;
2563-
pool->swork.diff = 1;
2564+
pool->next_diff = pool->swork.diff = 1;
25642565
if (opt_protocol) {
25652566
applog(LOG_DEBUG, "%s confirmed mining.subscribe with extranonce1 %s extran2size %d",
25662567
get_pool_name(pool), pool->nonce1, pool->n2size);

0 commit comments

Comments
 (0)