mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
init: Initialize globals with kernel::Context's life
...instead of explicitly calling init::{Set,Unset}Globals.
Cool thing about this is that in both the testing and bitcoin-chainstate
codepaths, we no longer need to explicitly unset globals. The
kernel::Context goes out of scope and the globals are unset
"automatically".
Also construct kernel::Context outside of AppInitSanityChecks()
This commit is contained in:
33
src/kernel/context.cpp
Normal file
33
src/kernel/context.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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 <key.h>
|
||||
#include <logging.h>
|
||||
#include <pubkey.h>
|
||||
#include <random.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace kernel {
|
||||
|
||||
Context::Context()
|
||||
{
|
||||
std::string sha256_algo = SHA256AutoDetect();
|
||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||
RandomInit();
|
||||
ECC_Start();
|
||||
ecc_verify_handle.reset(new ECCVerifyHandle());
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
ecc_verify_handle.reset();
|
||||
ECC_Stop();
|
||||
}
|
||||
|
||||
} // namespace kernel
|
||||
Reference in New Issue
Block a user