diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 1af2368..dfd83aa 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -828,12 +828,19 @@ void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp) void StratumServer::on_share_found(uv_work_t* req) { SubmittedShare* share = reinterpret_cast(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) { BACKGROUND_JOB_START(StratumServer::on_share_found); } StratumClient* client = share->m_client; - StratumServer* server = share->m_server; p2pool* pool = server->m_pool; 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: s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Invalid PoW\"}}\n"; break; + case SubmittedShare::Result::BANNED: + s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Banned\"}}\n"; + break; case SubmittedShare::Result::OK: s << "{\"id\":" << share->m_id << ",\"jsonrpc\":\"2.0\",\"error\":null,\"result\":{\"status\":\"OK\"}}\n"; break; diff --git a/src/stratum_server.h b/src/stratum_server.h index 5b5bec1..88c8dbd 100644 --- a/src/stratum_server.h +++ b/src/stratum_server.h @@ -152,6 +152,7 @@ private: COULDNT_CHECK_POW, LOW_DIFF, INVALID_POW, + BANNED, OK } m_result; };