From 2ce326a46221df788bca65bc66a38b6112c7face Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 27 Apr 2014 16:24:44 +1000 Subject: [PATCH] Clamp worker diff to network diff --- src/stratifier.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 72af9016..a2688ec6 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -657,7 +657,7 @@ out: static void add_submit(stratum_instance_t *client, int diff) { int next_blockid, optimal, share_duration; - double tdiff, drp, dsps; + double tdiff, drp, dsps, network_diff; json_t *json_msg; tv_t now_t; @@ -698,8 +698,15 @@ static void add_submit(stratum_instance_t *client, int diff) ck_rlock(&workbase_lock); next_blockid = workbase_id + 1; + network_diff = current_workbase->diff; ck_runlock(&workbase_lock); + if (optimal > network_diff) { + /* Intentionall round down here */ + optimal = network_diff; + if (client->diff == optimal) + return; + } client->ssdc = 0; /* We have the effect of a change pending */