diff options
| author | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-07 10:56:24 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-07 11:05:09 -0300 |
| commit | b72f403c054838e4b2203f48f757df0dad017628 (patch) | |
| tree | 239f171b37a354992433995d681421d85042e9aa | |
| parent | 4de5cca7e7a0a7104dae8d414add33f6e9562e4a (diff) | |
randomx: serialize cache initialization (#4)
| -rw-r--r-- | src/randomx_pow.cpp | 5 |
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; | |||
| 19 | static randomx_dataset* g_dataset = NULL; | 19 | static randomx_dataset* g_dataset = NULL; |
| 20 | static randomx_vm* g_vmVerify = NULL; | 20 | static randomx_vm* g_vmVerify = NULL; |
| 21 | static CCriticalSection g_csVerify; | 21 | static CCriticalSection g_csVerify; |
| 22 | static std::mutex g_csInit; | ||
| 22 | static bool g_fInit = false; | 23 | static bool g_fInit = false; |
| 23 | static bool g_fFast = false; | 24 | static 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 | ||