mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-02-03 11:46:27 +00:00
StratumServer: fixed data race
This commit is contained in:
parent
12a011a9ff
commit
03a3423da0
2 changed files with 6 additions and 3 deletions
|
@ -420,6 +420,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
||||||
uint64_t rem;
|
uint64_t rem;
|
||||||
share->m_hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 1;
|
share->m_hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 1;
|
||||||
share->m_highEnoughDifficulty = sidechain_diff.check_pow(resultHash);
|
share->m_highEnoughDifficulty = sidechain_diff.check_pow(resultHash);
|
||||||
|
share->m_score = 0;
|
||||||
|
|
||||||
// Don't count shares that were found during sync
|
// Don't count shares that were found during sync
|
||||||
const SideChain& side_chain = m_pool->side_chain();
|
const SideChain& side_chain = m_pool->side_chain();
|
||||||
|
@ -884,11 +885,11 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||||
if (pow_hash != share->m_resultHash) {
|
if (pow_hash != share->m_resultHash) {
|
||||||
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " submitted a share with invalid PoW");
|
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " submitted a share with invalid PoW");
|
||||||
share->m_result = SubmittedShare::Result::INVALID_POW;
|
share->m_result = SubmittedShare::Result::INVALID_POW;
|
||||||
client->m_score += BAD_SHARE_POINTS;
|
share->m_score = BAD_SHARE_POINTS;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
client->m_score += GOOD_SHARE_POINTS;
|
share->m_score = GOOD_SHARE_POINTS;
|
||||||
|
|
||||||
const double diff = sidechain_difficulty.to_double();
|
const double diff = sidechain_difficulty.to_double();
|
||||||
{
|
{
|
||||||
|
@ -924,7 +925,7 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||||
else {
|
else {
|
||||||
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " got a low diff share");
|
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " got a low diff share");
|
||||||
share->m_result = SubmittedShare::Result::LOW_DIFF;
|
share->m_result = SubmittedShare::Result::LOW_DIFF;
|
||||||
client->m_score += BAD_SHARE_POINTS;
|
share->m_score = BAD_SHARE_POINTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,6 +933,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||||
{
|
{
|
||||||
SubmittedShare* share = reinterpret_cast<SubmittedShare*>(req->data);
|
SubmittedShare* share = reinterpret_cast<SubmittedShare*>(req->data);
|
||||||
StratumClient* client = share->m_client;
|
StratumClient* client = share->m_client;
|
||||||
|
client->m_score += share->m_score;
|
||||||
|
|
||||||
if (share->m_highEnoughDifficulty) {
|
if (share->m_highEnoughDifficulty) {
|
||||||
const char* s = client->m_customUser;
|
const char* s = client->m_customUser;
|
||||||
|
|
|
@ -154,6 +154,7 @@ private:
|
||||||
uint64_t m_timestamp;
|
uint64_t m_timestamp;
|
||||||
uint64_t m_hashes;
|
uint64_t m_hashes;
|
||||||
bool m_highEnoughDifficulty;
|
bool m_highEnoughDifficulty;
|
||||||
|
int32_t m_score;
|
||||||
|
|
||||||
enum class Result {
|
enum class Result {
|
||||||
STALE,
|
STALE,
|
||||||
|
|
Loading…
Reference in a new issue