diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2020-10-30 16:25:56 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2020-12-04 11:03:28 -0400 |
commit | 6ee9cbdd18a70894f89dd268c276d5eb47a34827 (patch) | |
tree | da33c80e155d8c73e3680f24807bc54f33c175c7 /src | |
parent | 5aaeb6cf877055c47fa2bbd2ea5e8d3d2033933b (diff) | |
download | bitcoin-6ee9cbdd18a70894f89dd268c276d5eb47a34827.tar.xz |
refactor: Replace ListWalletDir() function with ListDatabases()
No change to behavior. This is just cleanup after previous MOVEONLY commit to
make db.h list function fit conventions of surrounding functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/db.cpp | 5 | ||||
-rw-r--r-- | src/wallet/db.h | 3 | ||||
-rw-r--r-- | src/wallet/interfaces.cpp | 2 | ||||
-rw-r--r-- | src/wallet/rpcwallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/walletutil.h | 3 |
5 files changed, 6 insertions, 9 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 85aeaeb3ab..e8b8b8abc1 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -10,8 +10,6 @@ #include <string> -fs::path GetWalletDir(); - #ifdef USE_BDB bool ExistsBerkeleyDatabase(const fs::path& path); #else @@ -23,9 +21,8 @@ bool ExistsSQLiteDatabase(const fs::path& path); # define ExistsSQLiteDatabase(path) (false) #endif -std::vector<fs::path> ListWalletDir() +std::vector<fs::path> ListDatabases(const fs::path& wallet_dir) { - const fs::path wallet_dir = GetWalletDir(); const size_t offset = wallet_dir.string().size() + 1; std::vector<fs::path> paths; boost::system::error_code ec; diff --git a/src/wallet/db.h b/src/wallet/db.h index cc13f887b0..3d18e5cec0 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -223,6 +223,9 @@ enum class DatabaseStatus { FAILED_ENCRYPT, }; +/** Recursively list database paths in directory. */ +std::vector<fs::path> ListDatabases(const fs::path& path); + std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error); bool IsBDBFile(const fs::path& path); diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 3fbba9ab92..46ef6eee3e 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -551,7 +551,7 @@ public: std::vector<std::string> listWalletDir() override { std::vector<std::string> paths; - for (auto& path : ListWalletDir()) { + for (auto& path : ListDatabases(GetWalletDir())) { paths.push_back(path.string()); } return paths; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7ea6a214b2..3802bb452a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2537,7 +2537,7 @@ static RPCHelpMan listwalletdir() [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { UniValue wallets(UniValue::VARR); - for (const auto& path : ListWalletDir()) { + for (const auto& path : ListDatabases(GetWalletDir())) { UniValue wallet(UniValue::VOBJ); wallet.pushKV("name", path.string()); wallets.push_back(wallet); diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index 27521abd81..d4143ceff4 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -65,9 +65,6 @@ enum WalletFlags : uint64_t { //! Get the path of the wallet directory. fs::path GetWalletDir(); -//! Get wallets in wallet directory. -std::vector<fs::path> ListWalletDir(); - /** Descriptor with some wallet metadata */ class WalletDescriptor { |