Browse Source

Clamp suggest diff to pool mindiff rather than handling pool mindiff separately

master
Con Kolivas 9 years ago
parent
commit
00a2f59707
  1. 14
      src/stratifier.c

14
src/stratifier.c

@ -5795,10 +5795,10 @@ static json_params_t
/* Implement support for the diff in the params as well as the originally /* 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 * documented form of placing diff within the method. Needs to be entered with
* client holding a ref count. */ * 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); json_t *arr_val = json_array_get(params_val, 0);
sdata_t *sdata = client->ckp->sdata;
int64_t sdiff; int64_t sdiff;
if (unlikely(!client_active(client))) { 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); LOGINFO("Failed to parse suggest_difficulty for client %"PRId64, client->id);
return; return;
} }
/* Clamp suggest diff to global pool mindiff */
if (sdiff < ckp->mindiff)
sdiff = ckp->mindiff;
if (sdiff == client->suggest_diff) if (sdiff == client->suggest_diff)
return; return;
client->suggest_diff = sdiff; client->suggest_diff = sdiff;
if (client->diff == sdiff) if (client->diff == sdiff)
return; return;
if (sdiff < client->ckp->mindiff)
client->diff = client->ckp->mindiff;
else
client->diff = sdiff; client->diff = sdiff;
stratum_send_diff(sdata, client); stratum_send_diff(ckp->sdata, client);
} }
/* Send diff first when sending the first stratum template after subscribing */ /* 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")) { if (cmdmatch(method, "mining.suggest")) {
suggest_diff(client, method, params_val); suggest_diff(ckp, client, method, params_val);
return; return;
} }

Loading…
Cancel
Save