mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-18 16:01:00 +02:00
Merge bitcoin/bitcoin#30537: kernel: Only setup kernel context globals once
93fb0e7897000072ea790a91816aea876718ad27 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-ACK 93fb0e7897000072ea790a91816aea876718ad27
maflcko:
ACK 93fb0e7897000072ea790a91816aea876718ad27 👝
tdb3:
re ACK 93fb0e7897000072ea790a91816aea876718ad27
Tree-SHA512: c8418c23b34883b9b6af2b93c48760a931c246c9190fae372fb808f573408d332f53ca43b9c783eef561c4a6681e2fb63f215c939b40a87d597c0518dabea22a
This commit is contained in:
commit
c6b4718112
@ -8,15 +8,18 @@
|
|||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
Context::Context()
|
Context::Context()
|
||||||
{
|
{
|
||||||
|
static std::once_flag globals_initialized{};
|
||||||
|
std::call_once(globals_initialized, []() {
|
||||||
std::string sha256_algo = SHA256AutoDetect();
|
std::string sha256_algo = SHA256AutoDetect();
|
||||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
LogInfo("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||||
RandomInit();
|
RandomInit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user