mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-08-20 05:28:47 -06:00
StratumServer: fixed "bad share" ban logic
This commit is contained in:
parent
52e5008bf4
commit
c9faa92098
@ -336,6 +336,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
|||||||
share->m_req.data = share;
|
share->m_req.data = share;
|
||||||
share->m_server = this;
|
share->m_server = this;
|
||||||
share->m_client = client;
|
share->m_client = client;
|
||||||
|
share->m_clientAddr = client->m_addr;
|
||||||
share->m_clientResetCounter = client->m_resetCounter.load();
|
share->m_clientResetCounter = client->m_resetCounter.load();
|
||||||
share->m_rpcId = client->m_rpcId;
|
share->m_rpcId = client->m_rpcId;
|
||||||
share->m_id = id;
|
share->m_id = id;
|
||||||
@ -672,6 +673,8 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||||||
StratumClient* client = share->m_client;
|
StratumClient* client = share->m_client;
|
||||||
StratumServer* server = share->m_server;
|
StratumServer* server = share->m_server;
|
||||||
|
|
||||||
|
const bool bad_share = (share->m_result == SubmittedShare::Result::LOW_DIFF) || (share->m_result == SubmittedShare::Result::INVALID_POW);
|
||||||
|
|
||||||
if ((client->m_resetCounter.load() == share->m_clientResetCounter) && (client->m_rpcId == share->m_rpcId)) {
|
if ((client->m_resetCounter.load() == share->m_clientResetCounter) && (client->m_rpcId == share->m_rpcId)) {
|
||||||
const bool result = server->send(client,
|
const bool result = server->send(client,
|
||||||
[share](void* buf)
|
[share](void* buf)
|
||||||
@ -697,7 +700,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||||||
return s.m_pos;
|
return s.m_pos;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((share->m_result == SubmittedShare::Result::LOW_DIFF) || (share->m_result == SubmittedShare::Result::INVALID_POW)) {
|
if (bad_share) {
|
||||||
client->ban(DEFAULT_BAN_TIME);
|
client->ban(DEFAULT_BAN_TIME);
|
||||||
client->close();
|
client->close();
|
||||||
}
|
}
|
||||||
@ -705,6 +708,9 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||||||
client->close();
|
client->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (bad_share) {
|
||||||
|
server->ban(share->m_clientAddr, DEFAULT_BAN_TIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StratumServer::StratumClient::StratumClient()
|
StratumServer::StratumClient::StratumClient()
|
||||||
|
@ -112,6 +112,7 @@ private:
|
|||||||
uv_work_t m_req;
|
uv_work_t m_req;
|
||||||
StratumServer* m_server;
|
StratumServer* m_server;
|
||||||
StratumClient* m_client;
|
StratumClient* m_client;
|
||||||
|
raw_ip m_clientAddr;
|
||||||
uint32_t m_clientResetCounter;
|
uint32_t m_clientResetCounter;
|
||||||
uint32_t m_rpcId;
|
uint32_t m_rpcId;
|
||||||
uint32_t m_id;
|
uint32_t m_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user