From 7bdeba4d08f70b0e0e6a0cfc4327dd3e27beefa7 Mon Sep 17 00:00:00 2001 From: cohcho Date: Tue, 6 Oct 2020 13:34:19 +0000 Subject: [PATCH] Nonce: refactor static init --- src/crypto/common/Nonce.cpp | 18 ++---------------- src/crypto/common/Nonce.h | 2 -- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/crypto/common/Nonce.cpp b/src/crypto/common/Nonce.cpp index 81cc80e43..bd23e54c1 100644 --- a/src/crypto/common/Nonce.cpp +++ b/src/crypto/common/Nonce.cpp @@ -28,28 +28,14 @@ namespace xmrig { - -std::atomic Nonce::m_paused; -std::atomic Nonce::m_sequence[Nonce::MAX]; +std::atomic Nonce::m_paused = {true}; +std::atomic Nonce::m_sequence[Nonce::MAX] = { {1}, {1}, {1} }; std::atomic Nonce::m_nonces[2] = { {0}, {0} }; -static Nonce nonce; - - } // namespace xmrig -xmrig::Nonce::Nonce() -{ - m_paused = true; - - for (auto &i : m_sequence) { - i = 1; - } -} - - bool xmrig::Nonce::next(uint8_t index, uint32_t *nonce, uint32_t reserveCount, uint64_t mask) { mask &= 0x7FFFFFFFFFFFFFFFULL; diff --git a/src/crypto/common/Nonce.h b/src/crypto/common/Nonce.h index 05c842987..7c0e6d49a 100644 --- a/src/crypto/common/Nonce.h +++ b/src/crypto/common/Nonce.h @@ -43,8 +43,6 @@ public: }; - Nonce(); - static inline bool isOutdated(Backend backend, uint64_t sequence) { return m_sequence[backend].load(std::memory_order_relaxed) != sequence; } static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed); } static inline uint64_t sequence(Backend backend) { return m_sequence[backend].load(std::memory_order_relaxed); }