Skip to content

Commit

Permalink
Apply immediately the first set_difficulty
Browse files Browse the repository at this point in the history
This is a workaround for pool, who send the first difficulty after notify
  • Loading branch information
bitbandi committed Aug 21, 2015
1 parent 661088e commit 9f9bde5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,9 @@ static bool parse_notify(struct pool *pool, json_t *val)
snprintf(pool->nbit, 9, "%s", nbit);
snprintf(pool->ntime, 9, "%s", ntime);
pool->swork.clean = clean;
pool->sdiff = pool->next_diff;
if (pool->next_diff > 0) {
pool->sdiff = pool->next_diff;
}
alloc_len = pool->coinbase_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;
pool->nonce2_offset = cb1_len + pool->n1_len;

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

cg_wlock(&pool->data_lock);
old_diff = pool->next_diff;
pool->next_diff = diff;
if (pool->next_diff > 0) {
old_diff = pool->next_diff;
pool->next_diff = diff;
} else {
old_diff = pool->sdiff;
pool->next_diff = pool->sdiff = diff;
}
cg_wunlock(&pool->data_lock);

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

0 comments on commit 9f9bde5

Please sign in to comment.