mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Drop signal CClientUIInterface::LoadWallet
This commit is contained in:
committed by
João Barbosa
parent
be50469217
commit
81ea66c30e
@@ -342,7 +342,6 @@ public:
|
||||
void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); }
|
||||
void initWarning(const std::string& message) override { InitWarning(message); }
|
||||
void initError(const std::string& message) override { InitError(message); }
|
||||
void loadWallet(std::unique_ptr<Wallet> wallet) override { ::uiInterface.LoadWallet(wallet); }
|
||||
void showProgress(const std::string& title, int progress, bool resume_possible) override
|
||||
{
|
||||
::uiInterface.ShowProgress(title, progress, resume_possible);
|
||||
|
||||
@@ -43,7 +43,7 @@ class Wallet;
|
||||
//! asynchronously
|
||||
//! (https://github.com/bitcoin/bitcoin/pull/10973#issuecomment-380101269).
|
||||
//!
|
||||
//! * The initMessages() and loadWallet() methods which the wallet uses to send
|
||||
//! * The initMessage() and showProgress() methods which the wallet uses to send
|
||||
//! notifications to the GUI should go away when GUI and wallet can directly
|
||||
//! communicate with each other without going through the node
|
||||
//! (https://github.com/bitcoin/bitcoin/pull/15288#discussion_r253321096).
|
||||
@@ -213,9 +213,6 @@ public:
|
||||
//! Send init error.
|
||||
virtual void initError(const std::string& message) = 0;
|
||||
|
||||
//! Send wallet load notification to the GUI.
|
||||
virtual void loadWallet(std::unique_ptr<Wallet> wallet) = 0;
|
||||
|
||||
//! Send progress indicator.
|
||||
virtual void showProgress(const std::string& title, int progress, bool resume_possible) = 0;
|
||||
|
||||
|
||||
@@ -22,6 +22,15 @@ public:
|
||||
boost::signals2::scoped_connection m_connection;
|
||||
};
|
||||
|
||||
class CleanupHandler : public Handler
|
||||
{
|
||||
public:
|
||||
explicit CleanupHandler(std::function<void()> cleanup) : m_cleanup(std::move(cleanup)) {}
|
||||
~CleanupHandler() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
|
||||
void disconnect() override { if (!m_cleanup) return; m_cleanup(); m_cleanup = nullptr; }
|
||||
std::function<void()> m_cleanup;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
|
||||
@@ -29,4 +38,9 @@ std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection)
|
||||
return MakeUnique<HandlerImpl>(std::move(connection));
|
||||
}
|
||||
|
||||
std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup)
|
||||
{
|
||||
return MakeUnique<CleanupHandler>(std::move(cleanup));
|
||||
}
|
||||
|
||||
} // namespace interfaces
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef BITCOIN_INTERFACES_HANDLER_H
|
||||
#define BITCOIN_INTERFACES_HANDLER_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
@@ -30,6 +31,9 @@ public:
|
||||
//! Return handler wrapping a boost signal connection.
|
||||
std::unique_ptr<Handler> MakeHandler(boost::signals2::connection connection);
|
||||
|
||||
//! Return handler wrapping a cleanup function.
|
||||
std::unique_ptr<Handler> MakeHandler(std::function<void()> cleanup);
|
||||
|
||||
} // namespace interfaces
|
||||
|
||||
#endif // BITCOIN_INTERFACES_HANDLER_H
|
||||
|
||||
@@ -42,11 +42,10 @@ std::vector<fs::path> ListWalletDir();
|
||||
std::vector<std::shared_ptr<CWallet>> GetWallets();
|
||||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::string& error, std::vector<std::string>& warnings);
|
||||
WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, std::string& error, std::vector<std::string>& warnings, std::shared_ptr<CWallet>& result);
|
||||
std::unique_ptr<interfaces::Handler> HandleLoadWallet(interfaces::Node::LoadWalletFn load_wallet);
|
||||
|
||||
namespace interfaces {
|
||||
|
||||
class Wallet;
|
||||
|
||||
namespace {
|
||||
|
||||
class NodeImpl : public Node
|
||||
@@ -282,7 +281,7 @@ public:
|
||||
}
|
||||
std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) override
|
||||
{
|
||||
return MakeHandler(::uiInterface.LoadWallet_connect([fn](std::unique_ptr<Wallet>& wallet) { fn(std::move(wallet)); }));
|
||||
return HandleLoadWallet(std::move(fn));
|
||||
}
|
||||
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user