From 2721b16c465ed2d5197ebcf4c4c50f6b497e19b9 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 24 Nov 2022 08:04:53 +0100 Subject: [PATCH] Miner: fixed data race --- src/miner.cpp | 4 +++- src/miner.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index b798277..ca083c4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -41,12 +41,14 @@ Miner::Miner(p2pool* pool, uint32_t threads) , m_startTimestamp(high_resolution_clock::now()) , m_nonce(0) , m_nonceTimestamp(m_startTimestamp) - , m_extraNonce(static_cast(pool->p2p_server()->get_random64())) , m_totalHashes(0) , m_sharesFound(0) , m_job{} , m_jobIndex{ 0 } { + std::random_device rd; + m_extraNonce = static_cast(rd()); + on_block(m_pool->block_template()); m_minerThreads.reserve(threads); diff --git a/src/miner.h b/src/miner.h index b82eee4..422e661 100644 --- a/src/miner.h +++ b/src/miner.h @@ -56,7 +56,7 @@ private: std::atomic m_nonce; std::chrono::high_resolution_clock::time_point m_nonceTimestamp; - const uint32_t m_extraNonce; + uint32_t m_extraNonce; std::atomic m_totalHashes; std::atomic m_sharesFound;