From b72f403c054838e4b2203f48f757df0dad017628 Mon Sep 17 00:00:00 2001 From: Nsable-sh Date: Fri, 7 Aug 2026 10:56:24 -0300 Subject: randomx: serialize cache initialization (#4) --- src/randomx_pow.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/randomx_pow.cpp') 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; static randomx_dataset* g_dataset = NULL; static randomx_vm* g_vmVerify = NULL; static CCriticalSection g_csVerify; +static std::mutex g_csInit; static bool g_fInit = false; static bool g_fFast = false; @@ -28,6 +29,10 @@ bool RandomXInit() if (g_fInit) return true; + std::lock_guard lock(g_csInit); + if (g_fInit) + return true; + // Detect the best flags for this CPU (JIT, hardware AES, Argon2). g_flags = randomx_get_flags(); -- cgit v1.2.3