StartumServer: moved warnings to log level 4

This commit is contained in:
SChernykh 2021-08-28 08:30:17 +02:00
parent 14bb308794
commit 0be078cb09

View file

@ -183,7 +183,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
for (size_t i = 0; job_id_str[i]; ++i) {
uint32_t d;
if (!from_hex(job_id_str[i], d)) {
LOGWARN(1, "client: invalid params ('job_id' is not a hex integer)");
LOGWARN(4, "client: invalid params ('job_id' is not a hex integer)");
return false;
}
job_id = (job_id << 4) + d;
@ -194,7 +194,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
for (int i = static_cast<int>(sizeof(uint32_t)) - 1; i >= 0; --i) {
uint32_t d[2];
if (!from_hex(nonce_str[i * 2], d[0]) || !from_hex(nonce_str[i * 2 + 1], d[1])) {
LOGWARN(1, "Client: invalid params ('nonce' is not a hex integer)");
LOGWARN(4, "Client: invalid params ('nonce' is not a hex integer)");
return false;
}
nonce = (nonce << 8) | (d[0] << 4) | d[1];
@ -251,7 +251,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
return true;
}
LOGWARN(1, "client: got a share with invalid job id");
LOGWARN(4, "client: got a share with invalid job id");
const bool result = send(client,
[id](void* buf)
@ -380,7 +380,7 @@ void StratumServer::on_share_found(uv_work_t* req)
const uint32_t blob_size = block.get_hashing_blob(share->m_templateId, share->m_extraNonce, blob, height, difficulty, sidechain_difficulty, seed_hash, nonce_offset);
if (!blob_size) {
LOGWARN(1, "client: got a stale share");
LOGWARN(4, "client: got a stale share");
share->m_result = SubmittedShare::Result::STALE;
return;
}
@ -392,7 +392,7 @@ void StratumServer::on_share_found(uv_work_t* req)
hash pow_hash;
if (!pool->calculate_hash(blob, blob_size, seed_hash, pow_hash)) {
LOGWARN(1, "client: couldn't check share PoW");
LOGWARN(4, "client: couldn't check share PoW");
share->m_result = SubmittedShare::Result::COULDNT_CHECK_POW;
return;
}
@ -406,7 +406,7 @@ void StratumServer::on_share_found(uv_work_t* req)
share->m_result = SubmittedShare::Result::OK;
}
else {
LOGWARN(1, "got a low diff share from " << static_cast<char*>(client->m_addrString));
LOGWARN(4, "got a low diff share from " << static_cast<char*>(client->m_addrString));
share->m_result = SubmittedShare::Result::LOW_DIFF;
}
@ -529,34 +529,34 @@ bool StratumServer::StratumClient::process_request(char* data, uint32_t /*size*/
{
rapidjson::Document doc;
if (doc.ParseInsitu(data).HasParseError()) {
LOGWARN(1, "client: invalid JSON request ('id' field not found)");
LOGWARN(4, "client: invalid JSON request (parse error)");
return false;
}
if (!doc.IsObject()) {
LOGWARN(1, "client: invalid JSON request (not an object)");
LOGWARN(4, "client: invalid JSON request (not an object)");
return false;
}
if (!doc.HasMember("id")) {
LOGWARN(1, "client: invalid JSON request ('id' field not found)");
LOGWARN(4, "client: invalid JSON request ('id' field not found)");
return false;
}
auto& id = doc["id"];
if (!id.IsUint()) {
LOGWARN(1, "client: invalid JSON request ('id' field is not an integer)");
LOGWARN(4, "client: invalid JSON request ('id' field is not an integer)");
return false;
}
if (!doc.HasMember("method")) {
LOGWARN(1, "client: invalid JSON request ('method' field not found)");
LOGWARN(4, "client: invalid JSON request ('method' field not found)");
return false;
}
auto& method = doc["method"];
if (!method.IsString()) {
LOGWARN(1, "client: invalid JSON request ('method' field is not a string)");
LOGWARN(4, "client: invalid JSON request ('method' field is not a string)");
return false;
}
@ -570,7 +570,7 @@ bool StratumServer::StratumClient::process_request(char* data, uint32_t /*size*/
return process_submit(doc, id.GetUint());
}
else {
LOGWARN(1, "client: invalid JSON request (unknown method)");
LOGWARN(4, "client: invalid JSON request (unknown method)");
return false;
}
@ -585,51 +585,51 @@ bool StratumServer::StratumClient::process_login(rapidjson::Document& /*doc*/, u
bool StratumServer::StratumClient::process_submit(rapidjson::Document& doc, uint32_t id)
{
if (!doc.HasMember("params")) {
LOGWARN(1, "client: invalid JSON request ('params' field not found)");
LOGWARN(4, "client: invalid JSON request ('params' field not found)");
return false;
}
auto& params = doc["params"];
if (!params.IsObject()) {
LOGWARN(1, "client: invalid JSON request ('params' field is not an object)");
LOGWARN(4, "client: invalid JSON request ('params' field is not an object)");
return false;
}
if (!params.HasMember("id")) {
LOGWARN(1, "client: invalid params ('id' field not found)");
LOGWARN(4, "client: invalid params ('id' field not found)");
return false;
}
auto& rpcId = params["id"];
if (!rpcId.IsString()) {
LOGWARN(1, "client: invalid params ('id' field is not a string)");
LOGWARN(4, "client: invalid params ('id' field is not a string)");
return false;
}
if (!params.HasMember("job_id")) {
LOGWARN(1, "client: invalid params ('job_id' field not found)");
LOGWARN(4, "client: invalid params ('job_id' field not found)");
return false;
}
auto& job_id = params["job_id"];
if (!job_id.IsString()) {
LOGWARN(1, "client: invalid params ('job_id' field is not a string)");
LOGWARN(4, "client: invalid params ('job_id' field is not a string)");
return false;
}
if (!params.HasMember("nonce")) {
LOGWARN(1, "client: invalid params ('nonce' field not found)");
LOGWARN(4, "client: invalid params ('nonce' field not found)");
return false;
}
auto& nonce = params["nonce"];
if (!nonce.IsString()) {
LOGWARN(1, "client: invalid params ('nonce' field is not a string)");
LOGWARN(4, "client: invalid params ('nonce' field is not a string)");
return false;
}
if (nonce.GetStringLength() != sizeof(uint32_t) * 2) {
LOGWARN(1, "client: invalid params ('nonce' field has invalid length)");
LOGWARN(4, "client: invalid params ('nonce' field has invalid length)");
return false;
}