mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-10 12:44:31 +00:00
StratumServer: check for bans before checking shares
This commit is contained in:
parent
001c9e937d
commit
a574e68bb7
2 changed files with 12 additions and 1 deletions
|
@ -828,12 +828,19 @@ void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp)
|
||||||
void StratumServer::on_share_found(uv_work_t* req)
|
void StratumServer::on_share_found(uv_work_t* req)
|
||||||
{
|
{
|
||||||
SubmittedShare* share = reinterpret_cast<SubmittedShare*>(req->data);
|
SubmittedShare* share = reinterpret_cast<SubmittedShare*>(req->data);
|
||||||
|
StratumServer* server = share->m_server;
|
||||||
|
|
||||||
|
if (server->is_banned(share->m_clientAddr)) {
|
||||||
|
share->m_highEnoughDifficulty = false;
|
||||||
|
share->m_result = SubmittedShare::Result::BANNED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (share->m_highEnoughDifficulty) {
|
if (share->m_highEnoughDifficulty) {
|
||||||
BACKGROUND_JOB_START(StratumServer::on_share_found);
|
BACKGROUND_JOB_START(StratumServer::on_share_found);
|
||||||
}
|
}
|
||||||
|
|
||||||
StratumClient* client = share->m_client;
|
StratumClient* client = share->m_client;
|
||||||
StratumServer* server = share->m_server;
|
|
||||||
p2pool* pool = server->m_pool;
|
p2pool* pool = server->m_pool;
|
||||||
|
|
||||||
const uint64_t target = share->m_target;
|
const uint64_t target = share->m_target;
|
||||||
|
@ -952,6 +959,9 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||||
case SubmittedShare::Result::INVALID_POW:
|
case SubmittedShare::Result::INVALID_POW:
|
||||||
s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Invalid PoW\"}}\n";
|
s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Invalid PoW\"}}\n";
|
||||||
break;
|
break;
|
||||||
|
case SubmittedShare::Result::BANNED:
|
||||||
|
s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Banned\"}}\n";
|
||||||
|
break;
|
||||||
case SubmittedShare::Result::OK:
|
case SubmittedShare::Result::OK:
|
||||||
s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":null,\"result\":{\"status\":\"OK\"}}\n";
|
s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":null,\"result\":{\"status\":\"OK\"}}\n";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -152,6 +152,7 @@ private:
|
||||||
COULDNT_CHECK_POW,
|
COULDNT_CHECK_POW,
|
||||||
LOW_DIFF,
|
LOW_DIFF,
|
||||||
INVALID_POW,
|
INVALID_POW,
|
||||||
|
BANNED,
|
||||||
OK
|
OK
|
||||||
} m_result;
|
} m_result;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue