mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-03 07:52:33 +02:00
wallet: let ListWalletDir do not iterate trough our blocksdata.
When WalletDir == DataDir we would have iterate trough our own node files to find wallets, that consumes time and could cause an unresponsive node. Github-Pull: #19419 Rebased-From: c730c7a6b6eb9f2e5138e2874ca7c5c269086bf3
This commit is contained in:
parent
96ec3b67a7
commit
dab9589e2d
@ -11,6 +11,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
@ -18,6 +19,24 @@
|
||||
namespace wallet {
|
||||
std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
|
||||
{
|
||||
const fs::path& data_dir = gArgs.GetDataDirNet();
|
||||
const fs::path& blocks_dir = gArgs.GetBlocksDirPath();
|
||||
|
||||
// Here we place the top level dirs we want to skip in case walletdir is datadir or blocksdir
|
||||
// Those directories are referenced in doc/files.md
|
||||
const std::set<fs::path> ignore_paths = {
|
||||
blocks_dir,
|
||||
data_dir / "blktree",
|
||||
data_dir / "blocks",
|
||||
data_dir / "chainstate",
|
||||
data_dir / "coins",
|
||||
data_dir / "database",
|
||||
data_dir / "indexes",
|
||||
data_dir / "regtest",
|
||||
data_dir / "signet",
|
||||
data_dir / "testnet3"
|
||||
};
|
||||
|
||||
std::vector<fs::path> paths;
|
||||
std::error_code ec;
|
||||
|
||||
@ -32,6 +51,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't want to iterate through those special node dirs
|
||||
if (ignore_paths.count(it->path())) {
|
||||
it.disable_recursion_pending();
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const fs::path path{it->path().lexically_relative(wallet_dir)};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user