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 = \
156
156
index/txindex.h \
157
157
indirectmap.h \
158
158
init.h \
159
+ init/common.h \
159
160
interfaces/chain.h \
160
161
interfaces/handler.h \
161
162
interfaces/node.h \
@@ -520,6 +521,7 @@ libbitcoin_common_a_SOURCES = \
520
521
core_read.cpp \
521
522
core_write.cpp \
522
523
external_signer.cpp \
524
+ init/common.cpp \
523
525
key.cpp \
524
526
key_io.cpp \
525
527
merkleblock.cpp \
Original file line number Diff line number Diff line change 22
22
#include < httpserver.h>
23
23
#include < index/blockfilterindex.h>
24
24
#include < index/txindex.h>
25
+ #include < init/common.h>
25
26
#include < interfaces/chain.h>
26
27
#include < interfaces/node.h>
27
- #include < key.h>
28
28
#include < mapport.h>
29
29
#include < miner.h>
30
30
#include < net.h>
@@ -151,8 +151,6 @@ static fs::path GetPidFile(const ArgsManager& args)
151
151
// shutdown thing.
152
152
//
153
153
154
- static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
155
-
156
154
void Interrupt (NodeContext& node)
157
155
{
158
156
InterruptHTTPServer ();
@@ -286,8 +284,7 @@ void Shutdown(NodeContext& node)
286
284
node.chain_clients .clear ();
287
285
UnregisterAllValidationInterfaces ();
288
286
GetMainSignals ().UnregisterBackgroundSignalScheduler ();
289
- globalVerifyHandle.reset ();
290
- ECC_Stop ();
287
+ init::UnsetGlobals ();
291
288
node.mempool .reset ();
292
289
node.fee_estimator .reset ();
293
290
node.chainman = nullptr ;
@@ -1148,12 +1145,7 @@ bool AppInitSanityChecks()
1148
1145
{
1149
1146
// ********************************************************* Step 4: sanity checks
1150
1147
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 ();
1157
1149
1158
1150
// Sanity check
1159
1151
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