From 00a2f5970794843244b6bdb0d590b4a8753f7630 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 2 Mar 2016 08:50:59 +1100 Subject: [PATCH] Clamp suggest diff to pool mindiff rather than handling pool mindiff separately --- src/stratifier.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 9cfe10fd..e8235774 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -5795,10 +5795,10 @@ static json_params_t /* Implement support for the diff in the params as well as the originally * documented form of placing diff within the method. Needs to be entered with * client holding a ref count. */ -static void suggest_diff(stratum_instance_t *client, const char *method, const json_t *params_val) +static void suggest_diff(ckpool_t *ckp, stratum_instance_t *client, const char *method, + const json_t *params_val) { json_t *arr_val = json_array_get(params_val, 0); - sdata_t *sdata = client->ckp->sdata; int64_t sdiff; if (unlikely(!client_active(client))) { @@ -5811,16 +5811,16 @@ static void suggest_diff(stratum_instance_t *client, const char *method, const j LOGINFO("Failed to parse suggest_difficulty for client %"PRId64, client->id); return; } + /* Clamp suggest diff to global pool mindiff */ + if (sdiff < ckp->mindiff) + sdiff = ckp->mindiff; if (sdiff == client->suggest_diff) return; client->suggest_diff = sdiff; if (client->diff == sdiff) return; - if (sdiff < client->ckp->mindiff) - client->diff = client->ckp->mindiff; - else - client->diff = sdiff; - stratum_send_diff(sdata, client); + client->diff = sdiff; + stratum_send_diff(ckp->sdata, client); } /* Send diff first when sending the first stratum template after subscribing */ @@ -6034,7 +6034,7 @@ static void parse_method(ckpool_t *ckp, sdata_t *sdata, stratum_instance_t *clie } if (cmdmatch(method, "mining.suggest")) { - suggest_diff(client, method, params_val); + suggest_diff(ckp, client, method, params_val); return; }