mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Remove direct node->wallet calls in init.cpp
Route calls during node initialization and shutdown that would happen between a node process and wallet processes through the serializable `Chain::Client` interface, rather than `WalletInitInterface` which is now simpler and only deals with early initialization and parameter interaction. This commit mostly does not change behavior. The only change is that the "Wallet disabled!" and "No wallet support compiled in!" messages are now logged earlier during startup.
This commit is contained in:
37
src/init.cpp
37
src/init.cpp
@@ -19,6 +19,7 @@
|
||||
#include <fs.h>
|
||||
#include <httpserver.h>
|
||||
#include <httprpc.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <index/txindex.h>
|
||||
#include <key.h>
|
||||
#include <validation.h>
|
||||
@@ -177,7 +178,9 @@ void Shutdown(InitInterfaces& interfaces)
|
||||
StopREST();
|
||||
StopRPC();
|
||||
StopHTTPServer();
|
||||
g_wallet_init_interface.Flush();
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
client->flush();
|
||||
}
|
||||
StopMapPort();
|
||||
|
||||
// Because these depend on each-other, we make sure that neither can be
|
||||
@@ -240,7 +243,9 @@ void Shutdown(InitInterfaces& interfaces)
|
||||
pcoinsdbview.reset();
|
||||
pblocktree.reset();
|
||||
}
|
||||
g_wallet_init_interface.Stop();
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
client->stop();
|
||||
}
|
||||
|
||||
#if ENABLE_ZMQ
|
||||
if (g_zmq_notification_interface) {
|
||||
@@ -260,7 +265,7 @@ void Shutdown(InitInterfaces& interfaces)
|
||||
UnregisterAllValidationInterfaces();
|
||||
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||
GetMainSignals().UnregisterWithMempoolSignals(mempool);
|
||||
g_wallet_init_interface.Close();
|
||||
interfaces.chain_clients.clear();
|
||||
globalVerifyHandle.reset();
|
||||
ECC_Stop();
|
||||
LogPrintf("%s: done\n", __func__);
|
||||
@@ -1222,11 +1227,19 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||
GetMainSignals().RegisterWithMempoolSignals(mempool);
|
||||
|
||||
// Create client interfaces for wallets that are supposed to be loaded
|
||||
// according to -wallet and -disablewallet options. This only constructs
|
||||
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
|
||||
// when load() and start() interface methods are called below.
|
||||
g_wallet_init_interface.Construct(interfaces);
|
||||
|
||||
/* Register RPC commands regardless of -server setting so they will be
|
||||
* available in the GUI RPC console even if external calls are disabled.
|
||||
*/
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
g_wallet_init_interface.RegisterRPC(tableRPC);
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
client->registerRpcs();
|
||||
}
|
||||
g_rpc_interfaces = &interfaces;
|
||||
#if ENABLE_ZMQ
|
||||
RegisterZMQRPCCommands(tableRPC);
|
||||
@@ -1245,7 +1258,11 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
}
|
||||
|
||||
// ********************************************************* Step 5: verify wallet database integrity
|
||||
if (!g_wallet_init_interface.Verify(*interfaces.chain)) return false;
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
if (!client->verify()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************* Step 6: network initialization
|
||||
// Note that we absolutely cannot open any actual connections
|
||||
@@ -1564,7 +1581,11 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
}
|
||||
|
||||
// ********************************************************* Step 9: load wallet
|
||||
if (!g_wallet_init_interface.Open(*interfaces.chain)) return false;
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
if (!client->load()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************* Step 10: data directory maintenance
|
||||
|
||||
@@ -1710,7 +1731,9 @@ bool AppInitMain(InitInterfaces& interfaces)
|
||||
SetRPCWarmupFinished();
|
||||
uiInterface.InitMessage(_("Done loading"));
|
||||
|
||||
g_wallet_init_interface.Start(scheduler);
|
||||
for (const auto& client : interfaces.chain_clients) {
|
||||
client->start(scheduler);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user