Skip to content

Commit

Permalink
Merge bitcoin#23842: scripted-diff: Rename interfaces::WalletClient t…
Browse files Browse the repository at this point in the history
…o interfaces::WalletLoader

ff5f6de scripted-diff: Rename interfaces::WalletClient to interfaces::WalletLoader (Russell Yanofsky)

Pull request description:

  Name has been confusing since it was introduced, and it was pointed in recent review club https://bitcoincore.reviews/10102 that it was particularly unclear how `interfaces::WalletClient` was different from `interfaces::Wallet`.

ACKs for top commit:
  w0xlt:
    ACK ff5f6de

Tree-SHA512: 26fa10baa457e76da1933adab187e9be61b8d76cff1cf2c73ad4320461c7e31fb9db07b7c2486998294826beb4a1aca255c14903920b443db6213e653c5f7e0a
  • Loading branch information
MarcoFalke committed Dec 23, 2021
2 parents f5c678e + ff5f6de commit f7367b8
Show file tree
Hide file tree
Showing 26 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/dummywallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace interfaces {
class Chain;
class Handler;
class Wallet;
class WalletClient;
class WalletLoader;
}

class DummyWalletInit : public WalletInitInterface {
Expand Down Expand Up @@ -64,7 +64,7 @@ std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
throw std::logic_error("Wallet function called in non-wallet build.");
}

std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args)
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/init/bitcoin-gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class BitcoinGuiInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
{
return MakeWalletClient(chain, *Assert(m_node.args));
return MakeWalletLoader(chain, *Assert(m_node.args));
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
interfaces::Ipc* ipc() override { return m_ipc.get(); }
Expand Down
4 changes: 2 additions & 2 deletions src/init/bitcoin-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class BitcoinNodeInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
{
return MakeWalletClient(chain, *Assert(m_node.args));
return MakeWalletLoader(chain, *Assert(m_node.args));
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
interfaces::Ipc* ipc() override { return m_ipc.get(); }
Expand Down
4 changes: 2 additions & 2 deletions src/init/bitcoin-qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class BitcoinQtInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
{
return MakeWalletClient(chain, *Assert(m_node.args));
return MakeWalletLoader(chain, *Assert(m_node.args));
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
NodeContext m_node;
Expand Down
4 changes: 2 additions & 2 deletions src/init/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class BitcoindInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletClient> makeWalletClient(interfaces::Chain& chain) override
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
{
return MakeWalletClient(chain, *Assert(m_node.args));
return MakeWalletLoader(chain, *Assert(m_node.args));
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
NodeContext& m_node;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace interfaces {
std::unique_ptr<Node> Init::makeNode() { return {}; }
std::unique_ptr<Chain> Init::makeChain() { return {}; }
std::unique_ptr<WalletClient> Init::makeWalletClient(Chain& chain) { return {}; }
std::unique_ptr<WalletLoader> Init::makeWalletLoader(Chain& chain) { return {}; }
std::unique_ptr<Echo> Init::makeEcho() { return {}; }
Ipc* Init::ipc() { return nullptr; }
} // namespace interfaces
4 changes: 2 additions & 2 deletions src/interfaces/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Chain;
class Echo;
class Ipc;
class Node;
class WalletClient;
class WalletLoader;

//! Initial interface created when a process is first started, and used to give
//! and get access to other interfaces (Node, Chain, Wallet, etc).
Expand All @@ -29,7 +29,7 @@ class Init
virtual ~Init() = default;
virtual std::unique_ptr<Node> makeNode();
virtual std::unique_ptr<Chain> makeChain();
virtual std::unique_ptr<WalletClient> makeWalletClient(Chain& chain);
virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain);
virtual std::unique_ptr<Echo> makeEcho();
virtual Ipc* ipc();
};
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct bilingual_str;

namespace interfaces {
class Handler;
class WalletClient;
class WalletLoader;
struct BlockTip;

//! Block and header tip information
Expand Down Expand Up @@ -187,8 +187,8 @@ class Node
//! Broadcast transaction.
virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;

//! Get wallet client.
virtual WalletClient& walletClient() = 0;
//! Get wallet loader.
virtual WalletLoader& walletLoader() = 0;

//! Register handler for init messages.
using InitMessageFn = std::function<void(const std::string& message)>;
Expand All @@ -210,7 +210,7 @@ class Node
using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>;
virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;

//! Register handler for wallet client constructed messages.
//! Register handler for wallet loader constructed messages.
using InitWalletFn = std::function<void()>;
virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Wallet
//! 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.
Expand Down Expand Up @@ -422,9 +422,9 @@ struct WalletTxOut
//! dummywallet.cpp and throws if the wallet component is not compiled.
std::unique_ptr<Wallet> MakeWallet(WalletContext& context, 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

Expand Down
4 changes: 2 additions & 2 deletions src/node/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace interfaces {
class Chain;
class ChainClient;
class Init;
class WalletClient;
class WalletLoader;
} // namespace interfaces

//! NodeContext struct containing references to chain state and connection
Expand Down Expand Up @@ -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 = [] {};

Expand Down
6 changes: 3 additions & 3 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using interfaces::FoundBlock;
using interfaces::Handler;
using interfaces::MakeHandler;
using interfaces::Node;
using interfaces::WalletClient;
using interfaces::WalletLoader;

namespace node {
namespace {
Expand Down Expand Up @@ -280,9 +280,9 @@ class NodeImpl : public Node
{
return BroadcastTransaction(*m_context, std::move(tx), err_string, max_tx_fee, /*relay=*/ true, /*wait_callback=*/ false);
}
WalletClient& walletClient() override
WalletLoader& walletLoader() override
{
return *Assert(m_context->wallet_client);
return *Assert(m_context->wallet_loader);
}
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
{
Expand Down
2 changes: 1 addition & 1 deletion src/node/ui_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CClientUIInterface
/** Progress message during initialization. */
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);

/** Wallet client created. */
/** Wallet loader created. */
ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, );

/** Number of network connections changed. */
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmoun
// On new transaction, make an info balloon
QString msg = tr("Date: %1\n").arg(date) +
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
if (m_node.walletClient().getWallets().size() > 1 && !walletName.isEmpty()) {
if (m_node.walletLoader().getWallets().size() > 1 && !walletName.isEmpty()) {
msg += tr("Wallet: %1\n").arg(walletName);
}
msg += tr("Type: %1\n").arg(type);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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));
});
Expand Down
6 changes: 3 additions & 3 deletions src/qt/test/addressbooktests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void EditAddressAndSubmit(
void TestAddAddressesToSendBook(interfaces::Node& node)
{
TestChain100Setup test;
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_client = wallet_client.get();
auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_loader = wallet_loader.get();
node.setContext(&test.m_node);
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
wallet->LoadWallet();
Expand Down Expand Up @@ -115,7 +115,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
OptionsModel optionsModel;
ClientModel clientModel(node, &optionsModel);
WalletContext& context = *node.walletClient().context();
WalletContext& context = *node.walletLoader().context();
AddWallet(context, wallet);
WalletModel walletModel(interfaces::MakeWallet(context, wallet), clientModel, platformStyle.get());
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
Expand Down
6 changes: 3 additions & 3 deletions src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void TestGUI(interfaces::Node& node)
for (int i = 0; i < 5; ++i) {
test.CreateAndProcessBlock({}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey()));
}
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_client = wallet_client.get();
auto wallet_loader = interfaces::MakeWalletLoader(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_loader = wallet_loader.get();
node.setContext(&test.m_node);
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
wallet->LoadWallet();
Expand Down Expand Up @@ -175,7 +175,7 @@ void TestGUI(interfaces::Node& node)
TransactionView transactionView(platformStyle.get());
OptionsModel optionsModel;
ClientModel clientModel(node, &optionsModel);
WalletContext& context = *node.walletClient().context();
WalletContext& context = *node.walletLoader().context();
AddWallet(context, wallet);
WalletModel walletModel(interfaces::MakeWallet(context, wallet), clientModel, platformStyle.get());
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
Expand Down
10 changes: 5 additions & 5 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ WalletController::WalletController(ClientModel& client_model, const PlatformStyl
, m_platform_style(platform_style)
, 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));
});

Expand All @@ -61,7 +61,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) {
Expand Down Expand Up @@ -255,7 +255,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));

Expand Down Expand Up @@ -336,7 +336,7 @@ void OpenWalletActivity::open(const std::string& path)
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));

Expand All @@ -359,7 +359,7 @@ void LoadWalletsActivity::load()
tr("Loading wallets…"));

QTimer::singleShot(0, worker(), [this] {
for (auto& wallet : node().walletClient().getWallets()) {
for (auto& wallet : node().walletLoader().getWallets()) {
m_wallet_controller->getOrCreateWallet(std::move(wallet));
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ QString WalletModel::getDisplayName() const

bool WalletModel::isMultiwallet()
{
return m_node.walletClient().getWallets().size() > 1;
return m_node.walletLoader().getWallets().size() > 1;
}

void WalletModel::refresh(bool pk_hash_only)
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void WalletInit::Construct(NodeContext& node) const
LogPrintf("Wallet disabled!\n");
return;
}
auto wallet_client = node.init->makeWalletClient(*node.chain);
node.wallet_client = wallet_client.get();
node.chain_clients.emplace_back(std::move(wallet_client));
auto wallet_loader = node.init->makeWalletLoader(*node.chain);
node.wallet_loader = wallet_loader.get();
node.chain_clients.emplace_back(std::move(wallet_loader));
}
14 changes: 7 additions & 7 deletions src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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;
Expand Down Expand Up @@ -510,15 +510,15 @@ class WalletImpl : public Wallet
std::shared_ptr<CWallet> m_wallet;
};

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(m_context); }
~WalletLoaderImpl() override { UnloadWallets(m_context); }

//! ChainClient methods
void registerRpcs() override
Expand All @@ -539,7 +539,7 @@ class WalletClientImpl : public WalletClient
void stop() override { return StopWallets(m_context); }
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;
Expand Down Expand Up @@ -600,8 +600,8 @@ class WalletClientImpl : public WalletClient
namespace interfaces {
std::unique_ptr<Wallet> MakeWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(context, wallet) : nullptr; }

std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args)
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
{
return std::make_unique<wallet::WalletClientImpl>(chain, args);
return std::make_unique<wallet::WalletLoaderImpl>(chain, args);
}
} // namespace interfaces
2 changes: 1 addition & 1 deletion src/wallet/test/init_test_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/init_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit f7367b8

Please sign in to comment.