File tree Expand file tree Collapse file tree 4 files changed +51
-11
lines changed Expand file tree Collapse file tree 4 files changed +51
-11
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ BITCOIN_CORE_H = \
156156 index/txindex.h \
157157 indirectmap.h \
158158 init.h \
159+ init/common.h \
159160 interfaces/chain.h \
160161 interfaces/handler.h \
161162 interfaces/node.h \
@@ -520,6 +521,7 @@ libbitcoin_common_a_SOURCES = \
520521 core_read.cpp \
521522 core_write.cpp \
522523 external_signer.cpp \
524+ init/common.cpp \
523525 key.cpp \
524526 key_io.cpp \
525527 merkleblock.cpp \
Original file line number Diff line number Diff line change 2222#include < httpserver.h>
2323#include < index/blockfilterindex.h>
2424#include < index/txindex.h>
25+ #include < init/common.h>
2526#include < interfaces/chain.h>
2627#include < interfaces/node.h>
27- #include < key.h>
2828#include < mapport.h>
2929#include < miner.h>
3030#include < net.h>
@@ -151,8 +151,6 @@ static fs::path GetPidFile(const ArgsManager& args)
151151// shutdown thing.
152152//
153153
154- static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
155-
156154void Interrupt (NodeContext& node)
157155{
158156 InterruptHTTPServer ();
@@ -286,8 +284,7 @@ void Shutdown(NodeContext& node)
286284 node.chain_clients .clear ();
287285 UnregisterAllValidationInterfaces ();
288286 GetMainSignals ().UnregisterBackgroundSignalScheduler ();
289- globalVerifyHandle.reset ();
290- ECC_Stop ();
287+ init::UnsetGlobals ();
291288 node.mempool .reset ();
292289 node.fee_estimator .reset ();
293290 node.chainman = nullptr ;
@@ -1148,12 +1145,7 @@ bool AppInitSanityChecks()
11481145{
11491146 // ********************************************************* Step 4: sanity checks
11501147
1151- // Initialize elliptic curve code
1152- std::string sha256_algo = SHA256AutoDetect ();
1153- LogPrintf (" Using the '%s' SHA256 implementation\n " , sha256_algo);
1154- RandomInit ();
1155- ECC_Start ();
1156- globalVerifyHandle.reset (new ECCVerifyHandle ());
1148+ init::SetGlobals ();
11571149
11581150 // Sanity check
11591151 if (!InitSanityCheck ())
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2021 The Bitcoin Core developers
2+ // Distributed under the MIT software license, see the accompanying
3+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+ #include < crypto/sha256.h>
6+ #include < key.h>
7+ #include < logging.h>
8+ #include < pubkey.h>
9+ #include < random.h>
10+
11+ #include < memory>
12+
13+ static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
14+
15+ namespace init {
16+ void SetGlobals ()
17+ {
18+ std::string sha256_algo = SHA256AutoDetect ();
19+ LogPrintf (" Using the '%s' SHA256 implementation\n " , sha256_algo);
20+ RandomInit ();
21+ ECC_Start ();
22+ globalVerifyHandle.reset (new ECCVerifyHandle ());
23+ }
24+
25+ void UnsetGlobals ()
26+ {
27+ globalVerifyHandle.reset ();
28+ ECC_Stop ();
29+ }
30+ } // namespace init
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2021 The Bitcoin Core developers
2+ // Distributed under the MIT software license, see the accompanying
3+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+ // ! @file
6+ // ! @brief Common init functions shared by bitcoin-node, bitcoin-wallet, etc.
7+
8+ #ifndef BITCOIN_INIT_COMMON_H
9+ #define BITCOIN_INIT_COMMON_H
10+
11+ namespace init {
12+ void SetGlobals ();
13+ void UnsetGlobals ();
14+ } // namespace init
15+
16+ #endif // BITCOIN_INIT_COMMON_H
You can’t perform that action at this time.
0 commit comments