From 08ea17dacb3f4959c1471e1dbe0df625e1d63672 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 2 Sep 2014 14:55:58 +1000 Subject: [PATCH] Resetting first share in diff calculations leads to overshoot. Revert it and start a new diff calculation period when the hashrate appears lower instead. --- src/stratifier.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index e12cbcdd..f31d4949 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1578,7 +1578,7 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, int diff, bool network_diff = current_workbase->network_diff; ck_runlock(&workbase_lock); - if (!client->first_share.tv_sec) { + if (unlikely(!client->first_share.tv_sec)) { copy_tv(&client->first_share, &now_t); copy_tv(&client->ldc, &now_t); } @@ -1618,7 +1618,6 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, int diff, bool if (diff != client->diff) { client->ssdc = 0; - client->first_share.tv_sec = 0; return; } @@ -1639,7 +1638,14 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, int diff, bool if (client->diff == optimal) return; - client->first_share.tv_sec = 0; + /* If this is the first share in a change, reset the last diff change + * to make sure the client hasn't just fallen back after a leave of + * absence */ + if (optimal < client->diff && client->ssdc == 1) { + copy_tv(&client->ldc, &now_t); + return; + } + client->ssdc = 0; LOGINFO("Client %d biased dsps %.2f dsps %.2f drr %.2f adjust diff from %ld to: %ld ",