stratum: also check early nonce is hexa

and remove double submit_bad++
This commit is contained in:
Tanguy Pruvot 2018-03-14 20:20:41 +01:00
parent 165e93bf29
commit f342017d31

View file

@ -406,8 +406,7 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
YAAMP_JOB_TEMPLATE *templ = job->templ; YAAMP_JOB_TEMPLATE *templ = job->templ;
if(strlen(nonce) != YAAMP_NONCE_SIZE*2) if(strlen(nonce) != YAAMP_NONCE_SIZE*2 || !ishexa(nonce, YAAMP_NONCE_SIZE*2)) {
{
client_submit_error(client, job, 20, "Invalid nonce size", extranonce2, ntime, nonce); client_submit_error(client, job, 20, "Invalid nonce size", extranonce2, ntime, nonce);
return true; return true;
} }
@ -451,13 +450,11 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
if (extranull) { if (extranull) {
debuglog("extranonce %s is empty!, should be %s - %s\n", extranonce2, extra1_id, client->sock->ip); debuglog("extranonce %s is empty!, should be %s - %s\n", extranonce2, extra1_id, client->sock->ip);
client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce); client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce);
client->submit_bad++;
return true; return true;
} }
if (extradiff) { if (extradiff) {
// some ccminer pre-release doesn't fill correctly the extranonce // some ccminer pre-release doesn't fill correctly the extranonce
client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce); client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce);
client->submit_bad++;
socket_send(client->sock, "{\"id\":null,\"method\":\"mining.set_extranonce\",\"params\":[\"%s\",%d]}\n", socket_send(client->sock, "{\"id\":null,\"method\":\"mining.set_extranonce\",\"params\":[\"%s\",%d]}\n",
client->extranonce1, client->extranonce2size); client->extranonce1, client->extranonce2size);
return true; return true;
@ -465,7 +462,6 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
} }
else if(!ishexa(extranonce2, client->extranonce2size*2)) { else if(!ishexa(extranonce2, client->extranonce2size*2)) {
client_submit_error(client, job, 27, "Invalid nonce2", extranonce2, ntime, nonce); client_submit_error(client, job, 27, "Invalid nonce2", extranonce2, ntime, nonce);
client->submit_bad++;
return true; return true;
} }