|
|
@ -2500,12 +2500,12 @@ out: |
|
|
|
if (client->first_invalid < client->last_share.tv_sec || !client->first_invalid) |
|
|
|
if (client->first_invalid < client->last_share.tv_sec || !client->first_invalid) |
|
|
|
client->first_invalid = now_t; |
|
|
|
client->first_invalid = now_t; |
|
|
|
else if (client->first_invalid && client->first_invalid < now_t - 120) { |
|
|
|
else if (client->first_invalid && client->first_invalid < now_t - 120) { |
|
|
|
LOGNOTICE("Client %d rejecting for 120s, disconnecting", client->id); |
|
|
|
LOGNOTICE("Client %"PRId64" rejecting for 120s, disconnecting", client->id); |
|
|
|
stratum_send_message(client, "Disconnecting for continuous invalid shares"); |
|
|
|
stratum_send_message(client, "Disconnecting for continuous invalid shares"); |
|
|
|
client->reject = 2; |
|
|
|
client->reject = 2; |
|
|
|
} else if (client->first_invalid && client->first_invalid < now_t - 60) { |
|
|
|
} else if (client->first_invalid && client->first_invalid < now_t - 60) { |
|
|
|
if (!client->reject) { |
|
|
|
if (!client->reject) { |
|
|
|
LOGINFO("Client %d rejecting for 60s, sending diff", client->id); |
|
|
|
LOGINFO("Client %"PRId64" rejecting for 60s, sending diff", client->id); |
|
|
|
stratum_send_diff(client); |
|
|
|
stratum_send_diff(client); |
|
|
|
client->reject = 1; |
|
|
|
client->reject = 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -2625,8 +2625,10 @@ static void set_worker_mindiff(ckpool_t *ckp, const char *workername, int mindif |
|
|
|
ck_runlock(&instance_lock); |
|
|
|
ck_runlock(&instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
/* They may just have not connected yet */ |
|
|
|
/* They may just have not connected yet */ |
|
|
|
if (!instance) |
|
|
|
if (!instance) { |
|
|
|
return LOGINFO("Failed to find user %s in set_worker_mindiff", username); |
|
|
|
LOGINFO("Failed to find user %s in set_worker_mindiff", username); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Then find the matching worker instance */ |
|
|
|
/* Then find the matching worker instance */ |
|
|
|
ck_rlock(&instance_lock); |
|
|
|
ck_rlock(&instance_lock); |
|
|
@ -2639,11 +2641,15 @@ static void set_worker_mindiff(ckpool_t *ckp, const char *workername, int mindif |
|
|
|
ck_runlock(&instance_lock); |
|
|
|
ck_runlock(&instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
/* They may just not be connected at the moment */ |
|
|
|
/* They may just not be connected at the moment */ |
|
|
|
if (!worker) |
|
|
|
if (!worker) { |
|
|
|
return LOGINFO("Failed to find worker %s in set_worker_mindiff", workername); |
|
|
|
LOGINFO("Failed to find worker %s in set_worker_mindiff", workername); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mindiff < 1) |
|
|
|
if (mindiff < 1) { |
|
|
|
return LOGINFO("Worker %s requested invalid diff %ld", worker->workername, mindiff); |
|
|
|
LOGINFO("Worker %s requested invalid diff %d", worker->workername, mindiff); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (mindiff < ckp->mindiff) |
|
|
|
if (mindiff < ckp->mindiff) |
|
|
|
mindiff = ckp->mindiff; |
|
|
|
mindiff = ckp->mindiff; |
|
|
|
if (mindiff == worker->mindiff) |
|
|
|
if (mindiff == worker->mindiff) |
|
|
@ -2676,12 +2682,16 @@ static void suggest_diff(stratum_instance_t *client, const char *method, json_t |
|
|
|
json_t *arr_val = json_array_get(params_val, 0); |
|
|
|
json_t *arr_val = json_array_get(params_val, 0); |
|
|
|
int64_t sdiff; |
|
|
|
int64_t sdiff; |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!client->authorised)) |
|
|
|
if (unlikely(!client->authorised)) { |
|
|
|
return LOGWARNING("Attempted to suggest diff on unauthorised client %ld", client->id); |
|
|
|
LOGWARNING("Attempted to suggest diff on unauthorised client %ld", client->id); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (arr_val && json_is_integer(arr_val)) |
|
|
|
if (arr_val && json_is_integer(arr_val)) |
|
|
|
sdiff = json_integer_value(arr_val); |
|
|
|
sdiff = json_integer_value(arr_val); |
|
|
|
else if (sscanf(method, "mining.suggest_difficulty(%ld", &sdiff) != 1) |
|
|
|
else if (sscanf(method, "mining.suggest_difficulty(%ld", &sdiff) != 1) { |
|
|
|
return LOGINFO("Failed to parse suggest_difficulty for client %ld", client->id); |
|
|
|
LOGINFO("Failed to parse suggest_difficulty for client %"PRId64, client->id); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (sdiff == client->suggest_diff) |
|
|
|
if (sdiff == client->suggest_diff) |
|
|
|
return; |
|
|
|
return; |
|
|
|
client->suggest_diff = sdiff; |
|
|
|
client->suggest_diff = sdiff; |
|
|
@ -2711,7 +2721,7 @@ static void parse_method(const int64_t client_id, json_t *id_val, json_t *method |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(client->reject == 2)) { |
|
|
|
if (unlikely(client->reject == 2)) { |
|
|
|
LOGINFO("Dropping client %d tagged for lazy invalidation", client_id); |
|
|
|
LOGINFO("Dropping client %"PRId64" tagged for lazy invalidation", client_id); |
|
|
|
snprintf(buf, 255, "dropclient=%ld", client->id); |
|
|
|
snprintf(buf, 255, "dropclient=%ld", client->id); |
|
|
|
send_proc(client->ckp->connector, buf); |
|
|
|
send_proc(client->ckp->connector, buf); |
|
|
|
return; |
|
|
|
return; |
|
|
|