merge bitcoin#23842: Rename interfaces::WalletClient to interfaces::WalletLoader

This commit is contained in:
Kittywhiskers Van Gogh 2023-08-24 13:40:24 +05:30 committed by PastaPastaPasta
parent 05b942470f
commit c2014e447b
17 changed files with 43 additions and 43 deletions

View File

@ -37,7 +37,7 @@ struct NodeContext;
namespace interfaces {
class Handler;
class WalletClient;
class WalletLoader;
struct BlockTip;
//! Interface for the src/evo part of a dash node (dashd process).
@ -284,8 +284,8 @@ public:
//! Get unspent outputs associated with a transaction.
virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0;
//! Get wallet client.
virtual WalletClient& walletClient() = 0;
//! Get wallet loader.
virtual WalletLoader& walletLoader() = 0;
//! Return interface for accessing evo related handler.
virtual EVO& evo() = 0;

View File

@ -349,7 +349,7 @@ public:
//! Wallet chain client that in addition to having chain client methods for
//! starting up, shutting down, and registering RPCs, also has additional
//! methods (called by the GUI) to load and create wallets.
class WalletClient : public ChainClient
class WalletLoader : public ChainClient
{
public:
//! Create new wallet.
@ -456,9 +456,9 @@ struct WalletTxOut
//! dummywallet.cpp and throws if the wallet component is not compiled.
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet);
//! Return implementation of ChainClient interface for a wallet client. This
//! Return implementation of ChainClient interface for a wallet loader. This
//! function will be undefined in builds where ENABLE_WALLET is false.
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args);
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args);
} // namespace interfaces

View File

@ -25,7 +25,7 @@ class CEvoDB;
namespace interfaces {
class Chain;
class ChainClient;
class WalletClient;
class WalletLoader;
} // namespace interfaces
//! NodeContext struct containing references to chain state and connection
@ -52,7 +52,7 @@ struct NodeContext {
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
//! Reference to chain client that should used to load or create wallets
//! opened by the gui.
interfaces::WalletClient* wallet_client{nullptr};
interfaces::WalletLoader* wallet_loader{nullptr};
std::unique_ptr<CScheduler> scheduler;
std::function<void()> rpc_interruption_point = [] {};
//! Dash

View File

@ -71,7 +71,7 @@ using interfaces::Handler;
using interfaces::LLMQ;
using interfaces::MakeHandler;
using interfaces::Node;
using interfaces::WalletClient;
using interfaces::WalletLoader;
namespace node {
namespace {
@ -431,9 +431,9 @@ public:
assert(std::addressof(::ChainstateActive()) == std::addressof(chainman().ActiveChainstate()));
return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin);
}
WalletClient& walletClient() override
WalletLoader& walletLoader() override
{
return *Assert(m_context->wallet_client);
return *Assert(m_context->wallet_loader);
}
EVO& evo() override { return m_evo; }

View File

@ -1357,7 +1357,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QStri
bool disableAppNap = !m_node.masternodeSync().isSynced();
#ifdef ENABLE_WALLET
if (enableWallet) {
for (const auto& wallet : m_node.walletClient().getWallets()) {
for (const auto& wallet : m_node.walletLoader().getWallets()) {
disableAppNap |= wallet->coinJoin().isMixing();
}
}
@ -1725,7 +1725,7 @@ void BitcoinGUI::showIncomingTransactions()
// On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(itx.date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(itx.unit, itx.amount, true));
if (m_node.walletClient().getWallets().size() > 1 && !itx.walletName.isEmpty()) {
if (m_node.walletLoader().getWallets().size() > 1 && !itx.walletName.isEmpty()) {
msg += tr("Wallet: %1\n").arg(itx.walletName);
}
msg += tr("Type: %1\n").arg(itx.type);

View File

@ -404,7 +404,7 @@ void OptionsDialog::on_okButton_clicked()
appearance->accept();
#ifdef ENABLE_WALLET
if (m_enable_wallet) {
for (auto& wallet : model->node().walletClient().getWallets()) {
for (auto& wallet : model->node().walletLoader().getWallets()) {
wallet->coinJoin().resetCachedBlocks();
wallet->markDirty();
}

View File

@ -189,7 +189,7 @@ void SplashScreen::handleLoadWallet()
{
#ifdef ENABLE_WALLET
if (!WalletModel::isWalletEnabled()) return;
m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false)));
m_connected_wallets.emplace_back(std::move(wallet));
});

View File

@ -34,11 +34,11 @@ WalletController::WalletController(ClientModel& client_model, QObject* parent)
, m_node(client_model.node())
, m_options_model(client_model.getOptionsModel())
{
m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
getOrCreateWallet(std::move(wallet));
});
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.walletClient().getWallets()) {
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.walletLoader().getWallets()) {
getOrCreateWallet(std::move(wallet));
}
@ -65,7 +65,7 @@ std::map<std::string, bool> WalletController::listWalletDir() const
{
QMutexLocker locker(&m_mutex);
std::map<std::string, bool> wallets;
for (const std::string& name : m_node.walletClient().listWalletDir()) {
for (const std::string& name : m_node.walletLoader().listWalletDir()) {
wallets[name] = false;
}
for (WalletModel* wallet_model : m_wallets) {
@ -228,7 +228,7 @@ void CreateWalletActivity::createWallet()
}
QTimer::singleShot(500, worker(), [this, name, flags] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletClient().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message);
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message);
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
@ -299,7 +299,7 @@ void OpenWalletActivity::open(const std::string& path)
showProgressDialog(tr("Opening Wallet <b>%1</b>...").arg(name.toHtmlEscaped()));
QTimer::singleShot(0, worker(), [this, path] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletClient().loadWallet(path, m_error_message, m_warning_message);
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().loadWallet(path, m_error_message, m_warning_message);
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));

View File

@ -606,7 +606,7 @@ QString WalletModel::getDisplayName() const
bool WalletModel::isMultiwallet()
{
return m_node.walletClient().getWallets().size() > 1;
return m_node.walletLoader().getWallets().size() > 1;
}
uint256 WalletModel::getLastBlockProcessed() const

View File

@ -185,9 +185,9 @@ void WalletInit::Construct(NodeContext& node) const
LogPrintf("Wallet disabled!\n");
return;
}
auto wallet_client = interfaces::MakeWalletClient(*node.chain, args);
node.wallet_client = wallet_client.get();
node.chain_clients.emplace_back(std::move(wallet_client));
auto wallet_loader = interfaces::MakeWalletLoader(*node.chain, args);
node.wallet_loader = wallet_loader.get();
node.chain_clients.emplace_back(std::move(wallet_loader));
}

View File

@ -38,7 +38,7 @@ using interfaces::MakeHandler;
using interfaces::Wallet;
using interfaces::WalletAddress;
using interfaces::WalletBalances;
using interfaces::WalletClient;
using interfaces::WalletLoader;
using interfaces::WalletOrderForm;
using interfaces::WalletTx;
using interfaces::WalletTxOut;
@ -601,15 +601,15 @@ public:
CoinJoinImpl m_coinjoin;
};
class WalletClientImpl : public WalletClient
class WalletLoaderImpl : public WalletLoader
{
public:
WalletClientImpl(Chain& chain, ArgsManager& args)
WalletLoaderImpl(Chain& chain, ArgsManager& args)
{
m_context.chain = &chain;
m_context.args = &args;
}
~WalletClientImpl() override { UnloadWallets(); }
~WalletLoaderImpl() override { UnloadWallets(); }
//! ChainClient methods
void registerRpcs() override
@ -628,7 +628,7 @@ public:
void stop() override { return StopWallets(); }
void setMockTime(int64_t time) override { return SetMockTime(time); }
//! WalletClient methods
//! WalletLoader methods
std::unique_ptr<Wallet> createWallet(const std::string& name, const SecureString& passphrase, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings) override
{
std::shared_ptr<CWallet> wallet;
@ -681,7 +681,7 @@ public:
namespace interfaces {
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(wallet) : nullptr; }
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args) {
return std::make_unique<wallet::WalletClientImpl>(chain, args);
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args) {
return std::make_unique<wallet::WalletLoaderImpl>(chain, args);
}
} // namespace interfaces

View File

@ -10,7 +10,7 @@
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{
m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
m_wallet_loader = MakeWalletLoader(*m_node.chain, *Assert(m_node.args));
std::string sep;
sep += fs::path::preferred_separator;

View File

@ -19,7 +19,7 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
fs::path m_datadir;
fs::path m_cwd;
std::map<std::string, fs::path> m_walletdir_path_cases;
std::unique_ptr<interfaces::WalletClient> m_wallet_client;
std::unique_ptr<interfaces::WalletLoader> m_wallet_loader;
};
#endif // BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H

View File

@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
SetWalletDir(m_walletdir_path_cases["default"]);
{
ASSERT_DEBUG_LOG("");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == true);
}
fs::path walletdir = gArgs.GetArg("-walletdir", "");
@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
SetWalletDir(m_walletdir_path_cases["custom"]);
{
ASSERT_DEBUG_LOG("");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == true);
}
fs::path walletdir = gArgs.GetArg("-walletdir", "");
@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
SetWalletDir(m_walletdir_path_cases["nonexistent"]);
{
ASSERT_DEBUG_LOG("does not exist");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == false);
}
}
@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
SetWalletDir(m_walletdir_path_cases["file"]);
{
ASSERT_DEBUG_LOG("is not a directory");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == false);
}
}
@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
SetWalletDir(m_walletdir_path_cases["relative"]);
{
ASSERT_DEBUG_LOG("is a relative path");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == false);
}
}
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
SetWalletDir(m_walletdir_path_cases["trailing"]);
{
ASSERT_DEBUG_LOG("");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == true);
}
fs::path walletdir = gArgs.GetArg("-walletdir", "");
@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
SetWalletDir(m_walletdir_path_cases["trailing2"]);
{
ASSERT_DEBUG_LOG("");
bool result = m_wallet_client->verify();
bool result = m_wallet_loader->verify();
BOOST_CHECK(result == true);
}
fs::path walletdir = gArgs.GetArg("-walletdir", "");

View File

@ -12,5 +12,5 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
bool fFirstRun;
m_wallet.LoadWallet(fFirstRun);
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
m_wallet_client->registerRpcs();
m_wallet_loader->registerRpcs();
}

View File

@ -20,7 +20,7 @@
struct WalletTestingSetup : public TestingSetup {
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args));
std::unique_ptr<interfaces::WalletLoader> m_wallet_loader = interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args));
CWallet m_wallet;
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
};

View File

@ -49,7 +49,7 @@ using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wall
//! Explicitly unload and delete the wallet.
// Blocks the current thread after signaling the unload intent so that all
// wallet clients release the wallet.
// wallet pointer owners release the wallet.
// Note that, when blocking is not required, the wallet is implicitly unloaded
// by the shared pointer deleter.
void UnloadWallet(std::shared_ptr<CWallet>&& wallet);