upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-07 10:56:24 -0300
committerBitflash <admin@bitflash.network>2026-08-07 11:05:09 -0300
commitb72f403c054838e4b2203f48f757df0dad017628 (patch)
tree239f171b37a354992433995d681421d85042e9aa
parent4de5cca7e7a0a7104dae8d414add33f6e9562e4a (diff)
randomx: serialize cache initialization (#4)
-rw-r--r--src/randomx_pow.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/randomx_pow.cpp b/src/randomx_pow.cpp
index d617ba2..1d058d4 100644
--- a/src/randomx_pow.cpp
+++ b/src/randomx_pow.cpp
@@ -19,6 +19,7 @@ static randomx_cache* g_cache = NULL;
19static randomx_dataset* g_dataset = NULL; 19static randomx_dataset* g_dataset = NULL;
20static randomx_vm* g_vmVerify = NULL; 20static randomx_vm* g_vmVerify = NULL;
21static CCriticalSection g_csVerify; 21static CCriticalSection g_csVerify;
22static std::mutex g_csInit;
22static bool g_fInit = false; 23static bool g_fInit = false;
23static bool g_fFast = false; 24static bool g_fFast = false;
24 25
@@ -28,6 +29,10 @@ bool RandomXInit()
28 if (g_fInit) 29 if (g_fInit)
29 return true; 30 return true;
30 31
32 std::lock_guard<std::mutex> lock(g_csInit);
33 if (g_fInit)
34 return true;
35
31 // Detect the best flags for this CPU (JIT, hardware AES, Argon2). 36 // Detect the best flags for this CPU (JIT, hardware AES, Argon2).
32 g_flags = randomx_get_flags(); 37 g_flags = randomx_get_flags();
33 38