Skip to content

Commit

Permalink
Merge pull request #418 from bitbandi/diffbug
Browse files Browse the repository at this point in the history
store the next difficulty
  • Loading branch information
troky committed Jul 19, 2015
2 parents 666641b + d0881e8 commit 8bf1c18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ struct pool {
unsigned char *coinbase;
size_t nonce2_offset;
unsigned char header_bin[128];
double next_diff;
int merkle_offset;

struct timeval tv_lastwork;
Expand Down
7 changes: 4 additions & 3 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->swork.nbit = nbit;
pool->swork.ntime = ntime;
pool->swork.clean = clean;
pool->swork.diff = pool->next_diff;
alloc_len = pool->swork.cb_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;
pool->nonce2_offset = cb1_len + pool->n1_len;

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

cg_wlock(&pool->data_lock);
old_diff = pool->swork.diff;
pool->swork.diff = diff;
old_diff = pool->next_diff;
pool->next_diff = diff;
cg_wunlock(&pool->data_lock);

if (old_diff != diff) {
Expand Down Expand Up @@ -2560,7 +2561,7 @@ bool initiate_stratum(struct pool *pool)
if (!pool->stratum_url)
pool->stratum_url = pool->sockaddr_url;
pool->stratum_active = true;
pool->swork.diff = 1;
pool->next_diff = pool->swork.diff = 1;
if (opt_protocol) {
applog(LOG_DEBUG, "%s confirmed mining.subscribe with extranonce1 %s extran2size %d",
get_pool_name(pool), pool->nonce1, pool->n2size);
Expand Down

1 comment on commit 8bf1c18

@umarka
Copy link

@umarka umarka commented on 8bf1c18 Sep 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p

Please sign in to comment.