mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
Merge bitcoin/bitcoin#30537: kernel: Only setup kernel context globals once
93fb0e7897
kernel: Only setup kernel context globals once (TheCharlatan) Pull request description: The globals setup by the function calls when creating a new kernel context only need to be setup once. Calling them multiple times may be wasteful and has no apparent benefit. Besides kernel users potentially creating multiple contexts, this change may also be useful for tests creating multiple setups. ACKs for top commit: stickies-v: re-ACK93fb0e7897
maflcko: ACK93fb0e7897
👝 tdb3: re ACK93fb0e7897
Tree-SHA512: c8418c23b34883b9b6af2b93c48760a931c246c9190fae372fb808f573408d332f53ca43b9c783eef561c4a6681e2fb63f215c939b40a87d597c0518dabea22a
This commit is contained in:
commit
c6b4718112
1 changed files with 7 additions and 4 deletions
|
@ -8,15 +8,18 @@
|
|||
#include <logging.h>
|
||||
#include <random.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace kernel {
|
||||
Context::Context()
|
||||
{
|
||||
std::string sha256_algo = SHA256AutoDetect();
|
||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||
RandomInit();
|
||||
static std::once_flag globals_initialized{};
|
||||
std::call_once(globals_initialized, []() {
|
||||
std::string sha256_algo = SHA256AutoDetect();
|
||||
LogInfo("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||
RandomInit();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue