|
|
@ -522,7 +522,6 @@ static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block) |
|
|
|
wb->logdir = ckalloc(len); |
|
|
|
wb->logdir = ckalloc(len); |
|
|
|
|
|
|
|
|
|
|
|
ck_wlock(&workbase_lock); |
|
|
|
ck_wlock(&workbase_lock); |
|
|
|
if (!ckp->proxy) |
|
|
|
|
|
|
|
wb->id = workbase_id++; |
|
|
|
wb->id = workbase_id++; |
|
|
|
|
|
|
|
|
|
|
|
if (strncmp(wb->prevhash, lasthash, 64)) { |
|
|
|
if (strncmp(wb->prevhash, lasthash, 64)) { |
|
|
@ -1408,7 +1407,7 @@ static double sane_tdiff(tv_t *end, tv_t *start) |
|
|
|
return tdiff; |
|
|
|
return tdiff; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void add_submit(stratum_instance_t *client, int diff, bool valid) |
|
|
|
static void add_submit(ckpool_t *ckp, stratum_instance_t *client, int diff, bool valid) |
|
|
|
{ |
|
|
|
{ |
|
|
|
double tdiff, bdiff, dsps, drr, network_diff, bias; |
|
|
|
double tdiff, bdiff, dsps, drr, network_diff, bias; |
|
|
|
int64_t next_blockid, optimal; |
|
|
|
int64_t next_blockid, optimal; |
|
|
@ -1418,6 +1417,9 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid) |
|
|
|
|
|
|
|
|
|
|
|
ck_rlock(&workbase_lock); |
|
|
|
ck_rlock(&workbase_lock); |
|
|
|
next_blockid = workbase_id + 1; |
|
|
|
next_blockid = workbase_id + 1; |
|
|
|
|
|
|
|
if (ckp->proxy) |
|
|
|
|
|
|
|
network_diff = current_workbase->diff; |
|
|
|
|
|
|
|
else |
|
|
|
network_diff = current_workbase->network_diff; |
|
|
|
network_diff = current_workbase->network_diff; |
|
|
|
ck_runlock(&workbase_lock); |
|
|
|
ck_runlock(&workbase_lock); |
|
|
|
|
|
|
|
|
|
|
@ -1451,12 +1453,10 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid) |
|
|
|
if (client->ssdc < 72 && tdiff < 240) |
|
|
|
if (client->ssdc < 72 && tdiff < 240) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (diff != client->diff) |
|
|
|
if (diff != client->diff) { |
|
|
|
return; |
|
|
|
client->ssdc = 0; |
|
|
|
|
|
|
|
|
|
|
|
/* We have the effect of a change pending */ |
|
|
|
|
|
|
|
if (client->diff_change_job_id >= next_blockid) |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Diff rate ratio */ |
|
|
|
/* Diff rate ratio */ |
|
|
|
dsps = client->dsps5 / bias; |
|
|
|
dsps = client->dsps5 / bias; |
|
|
@ -1467,23 +1467,18 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
optimal = round(dsps * 3.33); |
|
|
|
optimal = round(dsps * 3.33); |
|
|
|
if (optimal <= client->ckp->mindiff) { |
|
|
|
|
|
|
|
if (client->diff == client->ckp->mindiff) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
optimal = client->ckp->mindiff; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (optimal > network_diff) { |
|
|
|
|
|
|
|
/* Intentionally round down here */ |
|
|
|
|
|
|
|
optimal = network_diff; |
|
|
|
|
|
|
|
if (client->diff == optimal) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Don't drop diff to rapidly in case the client simply switched away
|
|
|
|
/* Don't drop diff to rapidly in case the client simply switched away
|
|
|
|
* and has just returned */ |
|
|
|
* and has just returned */ |
|
|
|
if (optimal < client->diff / 2) |
|
|
|
if (optimal < client->diff / 2) |
|
|
|
optimal = client->diff / 2; |
|
|
|
optimal = client->diff / 2; |
|
|
|
|
|
|
|
/* Clamp to mindiff ~ network_diff */ |
|
|
|
|
|
|
|
if (optimal < ckp->mindiff) |
|
|
|
|
|
|
|
optimal = ckp->mindiff; |
|
|
|
|
|
|
|
if (optimal > network_diff) |
|
|
|
|
|
|
|
optimal = network_diff; |
|
|
|
|
|
|
|
if (client->diff == optimal) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
client->ssdc = 0; |
|
|
|
client->ssdc = 0; |
|
|
|
|
|
|
|
|
|
|
|
LOGINFO("Client %d biased dsps %.2f dsps %.2f drr %.2f adjust diff from %ld to: %ld ", |
|
|
|
LOGINFO("Client %d biased dsps %.2f dsps %.2f drr %.2f adjust diff from %ld to: %ld ", |
|
|
@ -1510,8 +1505,8 @@ test_blocksolve(stratum_instance_t *client, workbase_t *wb, const uchar *data, c |
|
|
|
ckpool_t *ckp; |
|
|
|
ckpool_t *ckp; |
|
|
|
ts_t ts_now; |
|
|
|
ts_t ts_now; |
|
|
|
|
|
|
|
|
|
|
|
/* Submit anything over 95% of the diff in case of rounding errors */ |
|
|
|
/* Submit anything over 99% of the diff in case of rounding errors */ |
|
|
|
if (diff < current_workbase->network_diff * 0.95) |
|
|
|
if (diff < current_workbase->network_diff * 0.99) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
LOGWARNING("Possible block solve diff %f !", diff); |
|
|
|
LOGWARNING("Possible block solve diff %f !", diff); |
|
|
@ -1778,7 +1773,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, |
|
|
|
goto out_unlock; |
|
|
|
goto out_unlock; |
|
|
|
} |
|
|
|
} |
|
|
|
invalid = false; |
|
|
|
invalid = false; |
|
|
|
if (wb->proxy && sdiff > wdiff) |
|
|
|
if (wb->proxy && sdiff >= wdiff) |
|
|
|
submit = true; |
|
|
|
submit = true; |
|
|
|
out_unlock: |
|
|
|
out_unlock: |
|
|
|
ck_runlock(&workbase_lock); |
|
|
|
ck_runlock(&workbase_lock); |
|
|
@ -1812,7 +1807,7 @@ out_unlock: |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGINFO("Rejected client %d invalid share", client->id); |
|
|
|
LOGINFO("Rejected client %d invalid share", client->id); |
|
|
|
add_submit(client, diff, result); |
|
|
|
add_submit(ckp, client, diff, result); |
|
|
|
|
|
|
|
|
|
|
|
/* Now write to the pool's sharelog. */ |
|
|
|
/* Now write to the pool's sharelog. */ |
|
|
|
val = json_object(); |
|
|
|
val = json_object(); |
|
|
|