From 7ef0915aea84e8a9205f2b09a5b98c3a10a6ff56 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 29 Apr 2014 22:51:45 +1000 Subject: [PATCH] Fix thinko in diff rate ratio calculation that was making it recalculate diff every time --- src/stratifier.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 4851795a..6ddbaa05 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -738,7 +738,7 @@ out: static void add_submit(stratum_instance_t *client, int diff) { int next_blockid, optimal, share_duration; - double tdiff, drp, dsps, network_diff; + double tdiff, drr, dsps, network_diff; json_t *json_msg; tv_t now_t; @@ -764,11 +764,10 @@ static void add_submit(stratum_instance_t *client, int diff) } else dsps = client->dsps; - /* Diff rate product */ - drp = dsps / (double)client->diff; - /* Optimal rate product is 3.33, allow some hysteresis, clamping more - * aggressively high share rates than low. */ - if (drp > 3 && drp < 4) + /* Diff rate ratio */ + drr = dsps / (double)client->diff; + /* Optimal rate product is 0.3, allow some hysteresis. */ + if (drr > 0.2 && drr < 0.4) return; optimal = round(dsps * 3.33); @@ -784,7 +783,7 @@ static void add_submit(stratum_instance_t *client, int diff) ck_runlock(&workbase_lock); if (optimal > network_diff) { - /* Intentionall round down here */ + /* Intentionally round down here */ optimal = network_diff; if (client->diff == optimal) return; @@ -795,7 +794,8 @@ static void add_submit(stratum_instance_t *client, int diff) if (client->diff_change_job_id >= next_blockid) 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); client->diff_change_job_id = next_blockid;