mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 08:17:55 +00:00
Fixed data races
This commit is contained in:
parent
2807f9a51c
commit
0ce1558f54
4 changed files with 8 additions and 6 deletions
|
@ -668,9 +668,8 @@ void p2pool::update_block_template()
|
||||||
{
|
{
|
||||||
MinerData data = miner_data();
|
MinerData data = miner_data();
|
||||||
|
|
||||||
if (m_updateSeed) {
|
if (m_updateSeed.exchange(false)) {
|
||||||
m_hasher->set_seed_async(data.seed_hash);
|
m_hasher->set_seed_async(data.seed_hash);
|
||||||
m_updateSeed = false;
|
|
||||||
}
|
}
|
||||||
m_blockTemplate->update(data, *m_mempool, &m_params->m_wallet);
|
m_blockTemplate->update(data, *m_mempool, &m_params->m_wallet);
|
||||||
stratum_on_block();
|
stratum_on_block();
|
||||||
|
|
|
@ -119,7 +119,7 @@ private:
|
||||||
SideChain* m_sideChain;
|
SideChain* m_sideChain;
|
||||||
RandomX_Hasher_Base* m_hasher;
|
RandomX_Hasher_Base* m_hasher;
|
||||||
BlockTemplate* m_blockTemplate;
|
BlockTemplate* m_blockTemplate;
|
||||||
bool m_updateSeed;
|
std::atomic<bool> m_updateSeed;
|
||||||
Mempool* m_mempool;
|
Mempool* m_mempool;
|
||||||
|
|
||||||
mutable uv_rwlock_t m_mainchainLock;
|
mutable uv_rwlock_t m_mainchainLock;
|
||||||
|
|
|
@ -1228,11 +1228,14 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rate limit to no more than once in 60 seconds.
|
// Rate limit to no more than once in 60 seconds.
|
||||||
if (timestamp < m_apiLastUpdateTime + 60) {
|
uint64_t t = m_apiLastUpdateTime.load();
|
||||||
|
if (timestamp < t + 60) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_apiLastUpdateTime = timestamp;
|
if (!m_apiLastUpdateTime.compare_exchange_strong(t, timestamp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes;
|
uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes;
|
||||||
int64_t dt_15m, dt_1h, dt_24h;
|
int64_t dt_15m, dt_1h, dt_24h;
|
||||||
|
|
|
@ -188,7 +188,7 @@ private:
|
||||||
uint32_t m_totalFoundShares;
|
uint32_t m_totalFoundShares;
|
||||||
uint32_t m_totalFailedShares;
|
uint32_t m_totalFailedShares;
|
||||||
|
|
||||||
uint64_t m_apiLastUpdateTime;
|
std::atomic<uint64_t> m_apiLastUpdateTime;
|
||||||
|
|
||||||
void update_hashrate_data(uint64_t hashes, uint64_t timestamp);
|
void update_hashrate_data(uint64_t hashes, uint64_t timestamp);
|
||||||
void api_update_local_stats(uint64_t timestamp);
|
void api_update_local_stats(uint64_t timestamp);
|
||||||
|
|
Loading…
Reference in a new issue