Browse Source

Fix thinko in diff rate ratio calculation that was making it recalculate diff every time

master
Con Kolivas 11 years ago
parent
commit
7ef0915aea
  1. 16
      src/stratifier.c

16
src/stratifier.c

@ -738,7 +738,7 @@ out:
static void add_submit(stratum_instance_t *client, int diff) static void add_submit(stratum_instance_t *client, int diff)
{ {
int next_blockid, optimal, share_duration; int next_blockid, optimal, share_duration;
double tdiff, drp, dsps, network_diff; double tdiff, drr, dsps, network_diff;
json_t *json_msg; json_t *json_msg;
tv_t now_t; tv_t now_t;
@ -764,11 +764,10 @@ static void add_submit(stratum_instance_t *client, int diff)
} else } else
dsps = client->dsps; dsps = client->dsps;
/* Diff rate product */ /* Diff rate ratio */
drp = dsps / (double)client->diff; drr = dsps / (double)client->diff;
/* Optimal rate product is 3.33, allow some hysteresis, clamping more /* Optimal rate product is 0.3, allow some hysteresis. */
* aggressively high share rates than low. */ if (drr > 0.2 && drr < 0.4)
if (drp > 3 && drp < 4)
return; return;
optimal = round(dsps * 3.33); optimal = round(dsps * 3.33);
@ -784,7 +783,7 @@ static void add_submit(stratum_instance_t *client, int diff)
ck_runlock(&workbase_lock); ck_runlock(&workbase_lock);
if (optimal > network_diff) { if (optimal > network_diff) {
/* Intentionall round down here */ /* Intentionally round down here */
optimal = network_diff; optimal = network_diff;
if (client->diff == optimal) if (client->diff == optimal)
return; return;
@ -795,7 +794,8 @@ static void add_submit(stratum_instance_t *client, int diff)
if (client->diff_change_job_id >= next_blockid) if (client->diff_change_job_id >= next_blockid)
return; return;
LOGDEBUG("Client %d dsps %.1f adjust diff to: %d ", client->id, dsps, optimal); LOGINFO("Client %d dsps %.1f drr %.2f adjust diff from %d to: %d ", client->id,
dsps, drr, client->diff, optimal);
copy_tv(&client->ldc, &now_t); copy_tv(&client->ldc, &now_t);
client->diff_change_job_id = next_blockid; client->diff_change_job_id = next_blockid;

Loading…
Cancel
Save