refactor: Add path argument to FindSnapshotChainstateDir

Remove access to the global gArgs for getting the directory in
utxo_snapshot.

This is done in the context of the libbitcoinkernel project, wherein
reliance of libbitcoinkernel code on the global gArgs is incrementally
removed.
This commit is contained in:
TheCharlatan
2023-05-04 23:19:58 +02:00
parent ef95be334f
commit 8789b11114
4 changed files with 11 additions and 12 deletions

View File

@@ -4,7 +4,6 @@
#include <node/utxo_snapshot.h>
#include <common/args.h>
#include <logging.h>
#include <streams.h>
#include <sync.h>
@@ -82,10 +81,10 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
return base_blockhash;
}
std::optional<fs::path> FindSnapshotChainstateDir()
std::optional<fs::path> FindSnapshotChainstateDir(const fs::path& data_dir)
{
fs::path possible_dir =
gArgs.GetDataDirNet() / fs::u8path(strprintf("chainstate%s", SNAPSHOT_CHAINSTATE_SUFFIX));
data_dir / fs::u8path(strprintf("chainstate%s", SNAPSHOT_CHAINSTATE_SUFFIX));
if (fs::exists(possible_dir)) {
return possible_dir;

View File

@@ -67,7 +67,7 @@ constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot";
//! Return a path to the snapshot-based chainstate dir, if one exists.
std::optional<fs::path> FindSnapshotChainstateDir();
std::optional<fs::path> FindSnapshotChainstateDir(const fs::path& data_dir);
} // namespace node