Fixed data races

pull/166/head
SChernykh 2022-05-28 20:47:49 +02:00
parent cb147773b5
commit 9e7666d12f
3 changed files with 5 additions and 6 deletions

View File

@ -115,7 +115,7 @@ BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b)
m_extraNonceOffsetInTemplate = b.m_extraNonceOffsetInTemplate;
m_numTransactionHashes = b.m_numTransactionHashes;
m_prevId = b.m_prevId;
m_height = b.m_height;
m_height = b.m_height.load();
m_difficulty = b.m_difficulty;
m_seedHash = b.m_seedHash;
m_timestamp = b.m_timestamp;

View File

@ -50,7 +50,6 @@ public:
void update_tx_keys();
FORCEINLINE uint64_t height() const { return m_height; }
FORCEINLINE uint64_t timestamp() const { return m_timestamp; }
FORCEINLINE difficulty_type difficulty() const { return m_difficulty; }
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
@ -83,7 +82,7 @@ private:
size_t m_numTransactionHashes;
hash m_prevId;
uint64_t m_height;
std::atomic<uint64_t> m_height;
difficulty_type m_difficulty;
hash m_seedHash;

View File

@ -133,7 +133,7 @@ public:
void print_status() override;
void show_peers();
size_t peer_list_size() const { return m_peerList.size(); }
size_t peer_list_size() const { MutexLock lock(m_peerListLock); return m_peerList.size(); }
uint32_t max_outgoing_peers() const { return m_maxOutgoingPeers; }
uint32_t max_incoming_peers() const { return m_maxIncomingPeers; }
@ -181,7 +181,7 @@ private:
uint64_t m_peerId;
uv_mutex_t m_peerListLock;
mutable uv_mutex_t m_peerListLock;
struct Peer
{
@ -194,7 +194,7 @@ private:
std::vector<Peer> m_peerList;
std::vector<Peer> m_peerListMonero;
uint64_t m_peerListLastSaved;
std::atomic<uint64_t> m_peerListLastSaved;
struct Broadcast
{