From 9c11ef229216f39a756ce74bca65a246fa0c47bc Mon Sep 17 00:00:00 2001 From: wowario Date: Sun, 31 Aug 2025 15:15:58 +0300 Subject: [PATCH] only allocate slow hash before RX --- src/cryptonote_basic/miner.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 71b8f78cc..f9c6a1d0b 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -524,6 +524,7 @@ namespace cryptonote { const uint32_t th_local_index = m_thread_index++; // atomically increment, getting value before increment bool rx_set = false; + bool cn_allocated = false; MLOG_SET_THREAD_NAME(std::string("[miner ") + std::to_string(th_local_index) + "]"); MGINFO("Miner thread was started ["<< th_local_index << "]"); @@ -532,7 +533,6 @@ namespace cryptonote difficulty_type local_diff = 0; uint32_t local_template_ver = 0; block b; - slow_hash_allocate_state(); ++m_threads_active; while(!m_stop) { @@ -582,6 +582,12 @@ namespace cryptonote rx_set = true; } + if ((b.major_version < RX_BLOCK_VERSION) && !cn_allocated) + { + slow_hash_allocate_state(); + cn_allocated = true; + } + m_gbh(b, height, NULL, tools::get_max_concurrency(), h); if(check_hash(h, local_diff)) @@ -604,7 +610,7 @@ namespace cryptonote ++m_hashes; ++m_total_hashes; } - slow_hash_free_state(); + if (cn_allocated) slow_hash_free_state(); MGINFO("Miner thread stopped ["<< th_local_index << "]"); --m_threads_active; return true;