0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

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.
This commit is contained in:
Russell Yanofsky 2020-10-30 16:25:56 -04:00
parent 5aaeb6cf87
commit 6ee9cbdd18
5 changed files with 6 additions and 9 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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
{