mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-10 17:17:14 +01:00
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. Co-authored-by: stickies-v <stickies-v@protonmail.com>
26 lines
642 B
C++
26 lines
642 B
C++
// Copyright (c) 2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <kernel/context.h>
|
|
|
|
#include <crypto/sha256.h>
|
|
#include <logging.h>
|
|
#include <random.h>
|
|
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
namespace kernel {
|
|
Context::Context()
|
|
{
|
|
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();
|
|
});
|
|
}
|
|
|
|
|
|
} // namespace kernel
|