Skip to content

Commit 7f0f853

Browse files
committed
Merge bitcoin/bitcoin#23005: multiprocess: Delay wallet client construction
ad085f9 multiprocess: Delay wallet client construction (Russell Yanofsky) Pull request description: Delay wallet client construction until after logging, thread and other init for two reasons: - More responsive multiprocess GUI startup. When bitcoin-gui is started this moves the call from bitcoin-gui to bitcoin-node that spawns bitcoin-wallet off of the GUI event thread and onto the background GUI init executor thread. - Avoids feature_logging.py test failures with bitcoin-node by making bitcoin-wallet logging start after bitcoin-node logging starts, because the tests are not written to handle the bitcoin-wallet logging init code running first. This partially reverts commit b266b3e, moving wallet client creation back to the place it was located before. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). ACKs for top commit: laanwj: code review ACK ad085f9 hebasto: ACK ad085f9, I have reviewed the code and it looks OK. Tree-SHA512: 74d957ce2ee096db745c517124f60800185814b06c20db676090e10dce1b90311adbab02865a69731f8c39b9365f9ee14be0830ca1368cac9b474801ea92bad5
2 parents 15d1098 + ad085f9 commit 7f0f853

File tree

8 files changed

+23
-6
lines changed

8 files changed

+23
-6
lines changed

src/init.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,6 @@ bool AppInitLockDataDirectory()
11021102
bool AppInitInterfaces(NodeContext& node)
11031103
{
11041104
node.chain = node.init->makeChain();
1105-
// Create client interfaces for wallets that are supposed to be loaded
1106-
// according to -wallet and -disablewallet options. This only constructs
1107-
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
1108-
// when load() and start() interface methods are called below.
1109-
g_wallet_init_interface.Construct(node);
11101105
return true;
11111106
}
11121107

@@ -1170,6 +1165,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11701165

11711166
GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);
11721167

1168+
// Create client interfaces for wallets that are supposed to be loaded
1169+
// according to -wallet and -disablewallet options. This only constructs
1170+
// the interfaces, it doesn't load wallet data. Wallets actually get loaded
1171+
// when load() and start() interface methods are called below.
1172+
g_wallet_init_interface.Construct(node);
1173+
uiInterface.InitWallet();
1174+
11731175
/* Register RPC commands regardless of -server setting so they will be
11741176
* available in the GUI RPC console even if external calls are disabled.
11751177
*/

src/interfaces/node.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ class Node
206206
using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>;
207207
virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;
208208

209+
//! Register handler for wallet client constructed messages.
210+
using InitWalletFn = std::function<void()>;
211+
virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;
212+
209213
//! Register handler for number of connections changed messages.
210214
using NotifyNumConnectionsChangedFn = std::function<void(int new_num_connections)>;
211215
virtual std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0;

src/node/interfaces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ class NodeImpl : public Node
296296
{
297297
return MakeHandler(::uiInterface.ShowProgress_connect(fn));
298298
}
299+
std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) override
300+
{
301+
return MakeHandler(::uiInterface.InitWallet_connect(fn));
302+
}
299303
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override
300304
{
301305
return MakeHandler(::uiInterface.NotifyNumConnectionsChanged_connect(fn));

src/node/ui_interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct UISignals {
1515
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value<bool>> ThreadSafeMessageBox;
1616
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value<bool>> ThreadSafeQuestion;
1717
boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
18+
boost::signals2::signal<CClientUIInterface::InitWalletSig> InitWallet;
1819
boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
1920
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
2021
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
@@ -34,6 +35,7 @@ static UISignals g_ui_signals;
3435
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
3536
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
3637
ADD_SIGNALS_IMPL_WRAPPER(InitMessage);
38+
ADD_SIGNALS_IMPL_WRAPPER(InitWallet);
3739
ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
3840
ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
3941
ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
@@ -45,6 +47,7 @@ ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
4547
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
4648
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
4749
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
50+
void CClientUIInterface::InitWallet() { return g_ui_signals.InitWallet(); }
4851
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
4952
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
5053
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }

src/node/ui_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class CClientUIInterface
8282
/** Progress message during initialization. */
8383
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
8484

85+
/** Wallet client created. */
86+
ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, );
87+
8588
/** Number of network connections changed. */
8689
ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections);
8790

src/qt/bitcoin.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
273273
// We don't hold a direct pointer to the splash screen after creation, but the splash
274274
// screen will take care of deleting itself when finish() happens.
275275
m_splash->show();
276-
connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet);
277276
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
278277
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
279278
}

src/qt/splashscreen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void SplashScreen::subscribeToCoreSignals()
194194
// Connect signals to client
195195
m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
196196
m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
197+
m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); });
197198
}
198199

199200
void SplashScreen::handleLoadWallet()

src/qt/splashscreen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public Q_SLOTS:
6666
bool m_shutdown = false;
6767
std::unique_ptr<interfaces::Handler> m_handler_init_message;
6868
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
69+
std::unique_ptr<interfaces::Handler> m_handler_init_wallet;
6970
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
7071
std::list<std::unique_ptr<interfaces::Wallet>> m_connected_wallets;
7172
std::list<std::unique_ptr<interfaces::Handler>> m_connected_wallet_handlers;

0 commit comments

Comments
 (0)