Skip to content

Commit

Permalink
Merge bitcoin#21850: Remove GetDataDir(net_specific) function
Browse files Browse the repository at this point in the history
aca0e5d Remove `GetDataDir(bool fNetSpecific = true)` function (Kiminuo)
b3e67f2 scripted-diff: Replace `GetDataDir(true)` calls with `gArgs.GetDataDirNet()` calls (Kiminuo)
4c3a5dc scripted-diff: Replace `GetDataDir()` calls with `gArgs.GetDataDirNet()` calls (Kiminuo)
13bd8bb Make `ArgsManager.GetDataDirPath` private and drop needless suffix (Kiminuo)
4d8189f scripted-diff: Change `ArgsManager.GetDataDirPath()` to `ArgsManager.GetDataDirBase()` in tests (Kiminuo)
0f53df4 Add `ArgsManager.GetDataDirBase()` and `ArgsManager.GetDataDirNet()` as an intended replacement for `ArgsManager.GetDataDirPath(net_identifier)` (Kiminuo)
716de29 Make `m_cached_blocks_path` mutable. Make `ArgsManager::GetBlocksDirPath()` const. (Kiminuo)

Pull request description:

  This PR is a follow up PR to bitcoin#21244. The PR attempts to move us an inch towards the [goal](bitcoin#21244 (comment)) by removing `GetDataDir(net_specific)` and replacing it by `gArgs.GetDataDir(net_specific)` calls.

  The approach of this PR attempts to be similar to the one chosen in "De-globalize ChainstateManager" (bitcoin#20158). The goal is to pass `ArgsManager` to functions (or ideally to have `ArgsManager` as a member of a class where needed; inspiration from here: bitcoin#21789) instead of having it as a global variable (i.e. `gArgs`).

  **Notes:**
  * First commit makes `m_cached_blocks_path` `mutable` as was suggested [here](bitcoin#21244 (comment)) but not fully applied in bitcoin#21244. (`m_cached_datadir_path` and `m_cached_network_datadir_path` were marked as `mutable` in bitcoin#21244) This commit can be in a separate PR too.
  * Other commits deal with removing of `GetDataDir(net_specific)` function.
      * This was originally part of bitcoin#21244 but it was [left]((bitcoin#21244 (review))) for a follow up PR.
  * I think that the proposed changes show nicely where there is reliance on `gArgs` which is IMO a good thing.

  If you know about a better approach how to do this, please share it here.

ACKs for top commit:
  hebasto:
    ACK aca0e5d
  MarcoFalke:
    re-ACK aca0e5d 👃

Tree-SHA512: deec4d88edb32d7f4c818c3a74ffbb64709685819b88242dcf5dbaa1fb611f3ce2b29d2576ddb9e0dc5e75288e43538968224008c0a80e7149fc81c309f7c9da
  • Loading branch information
MarcoFalke authored and vijaydasmp committed Feb 3, 2024
1 parent f9e8062 commit 713bb68
Show file tree
Hide file tree
Showing 35 changed files with 97 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
std::string tmpfn = strprintf("%s.%04x", prefix, randv);

// open temp output file, and associate with CAutoFile
fs::path pathTmp = GetDataDir() / tmpfn;
fs::path pathTmp = gArgs.GetDataDirNet() / tmpfn;
FILE *file = fsbridge::fopen(pathTmp, "wb");
CAutoFile fileout(file, SER_DISK, version);
if (fileout.IsNull()) {
Expand Down Expand Up @@ -230,7 +230,7 @@ bool CBanDB::Read(banmap_t& banSet)

CAddrDB::CAddrDB()
{
pathAddr = GetDataDir() / "peers.dat";
pathAddr = gArgs.GetDataDirNet() / "peers.dat";
}

bool CAddrDB::Write(const CAddrMan& addr)
Expand Down
2 changes: 1 addition & 1 deletion src/index/blockfilterindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
const std::string& filter_name = BlockFilterTypeName(filter_type);
if (filter_name.empty()) throw std::invalid_argument("unknown filter_type");

fs::path path = GetDataDir() / "indexes" / "blockfilter" / filter_name;
fs::path path = gArgs.GetDataDirNet() / "indexes" / "blockfilter" / filter_name;
fs::create_directories(path);

m_name = filter_name + " block filter index";
Expand Down
2 changes: 1 addition & 1 deletion src/index/coinstatsindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ std::unique_ptr<CoinStatsIndex> g_coin_stats_index;

CoinStatsIndex::CoinStatsIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
{
fs::path path{GetDataDir() / "indexes" / "coinstats"};
fs::path path{gArgs.GetDataDirNet() / "indexes" / "coinstats"};
fs::create_directories(path);

m_db = std::make_unique<CoinStatsIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
Expand Down
2 changes: 1 addition & 1 deletion src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TxIndex::DB : public BaseIndex::DB
};

TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) :
BaseIndex::DB(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
BaseIndex::DB(gArgs.GetDataDirNet() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
{}

bool TxIndex::DB::ReadTxPos(const uint256 &txid, CDiskTxPos& pos) const
Expand Down
10 changes: 5 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
static bool LockDataDirectory(bool probeOnly)
{
// Make sure only a single Dash Core process is using the data directory.
fs::path datadir = GetDataDir();
fs::path datadir = gArgs.GetDataDirNet();
if (!DirIsWritable(datadir)) {
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), datadir.string()));
}
Expand Down Expand Up @@ -1595,7 +1595,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
assert(!node.addrman);
node.addrman = std::make_unique<CAddrMan>();
assert(!node.banman);
node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
node.banman = std::make_unique<BanMan>(gArgs.GetDataDirNet() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
assert(!node.connman);
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), *node.addrman);

Expand Down Expand Up @@ -1744,7 +1744,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
asmap_path = DEFAULT_ASMAP_FILENAME;
}
if (!asmap_path.is_absolute()) {
asmap_path = GetDataDir() / asmap_path;
asmap_path = gArgs.GetDataDirNet() / asmap_path;
}
if (!fs::exists(asmap_path)) {
InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
Expand Down Expand Up @@ -2251,8 +2251,8 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc

// ********************************************************* Step 11: import blocks

if (!CheckDiskSpace(GetDataDir())) {
InitError(strprintf(_("Error: Disk space is low for %s"), GetDataDir()));
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
InitError(strprintf(_("Error: Disk space is low for %s"), gArgs.GetDataDirNet()));
return false;
}
if (!CheckDiskSpace(gArgs.GetBlocksDirPath())) {
Expand Down
2 changes: 1 addition & 1 deletion src/init/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool StartLogging(const ArgsManager& args)
if (!LogInstance().m_log_timestamps)
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
LogPrintf("Using data directory %s\n", GetDataDir().string());
LogPrintf("Using data directory %s\n", gArgs.GetDataDirNet().string());

// Only log conf file usage message if conf file actually exists.
fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME));
Expand Down
6 changes: 3 additions & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)

proxyType i2p_sam;
if (GetProxy(NET_I2P, i2p_sam)) {
m_i2p_sam_session = std::make_unique<i2p::sam::Session>(GetDataDir() / "i2p_private_key",
m_i2p_sam_session = std::make_unique<i2p::sam::Session>(gArgs.GetDataDirNet() / "i2p_private_key",
i2p_sam.proxy, &interruptNet);
}

Expand All @@ -3191,7 +3191,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)

if (m_use_addrman_outgoing) {
// Load addresses from anchors.dat
m_anchors = ReadAnchors(GetDataDir() / ANCHORS_DATABASE_FILENAME);
m_anchors = ReadAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME);
if (m_anchors.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
m_anchors.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
}
Expand Down Expand Up @@ -3384,7 +3384,7 @@ void CConnman::StopNodes()
if (anchors_to_dump.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
anchors_to_dump.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
}
DumpAnchors(GetDataDir() / ANCHORS_DATABASE_FILENAME, anchors_to_dump);
DumpAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME, anchors_to_dump);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/policy/fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
longStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE);

// If the fee estimation file is present, read recorded estimations
fs::path est_filepath = GetDataDir() / FEE_ESTIMATES_FILENAME;
fs::path est_filepath = gArgs.GetDataDirNet() / FEE_ESTIMATES_FILENAME;
CAutoFile est_file(fsbridge::fopen(est_filepath, "rb"), SER_DISK, CLIENT_VERSION);
if (est_file.IsNull() || !Read(est_file)) {
LogPrintf("Failed to read fee estimates from %s. Continue anyway.\n", est_filepath.string());
Expand Down Expand Up @@ -869,7 +869,7 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation
void CBlockPolicyEstimator::Flush() {
FlushUnconfirmed();

fs::path est_filepath = GetDataDir() / FEE_ESTIMATES_FILENAME;
fs::path est_filepath = gArgs.GetDataDirNet() / FEE_ESTIMATES_FILENAME;
CAutoFile est_file(fsbridge::fopen(est_filepath, "wb"), SER_DISK, CLIENT_VERSION);
if (est_file.IsNull() || !Write(est_file)) {
LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", est_filepath.string());
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ int GuiMain(int argc, char* argv[])
if (!Intro::showIfNeeded(did_show_intro, prune)) return EXIT_SUCCESS;

/// 6. Determine availability of data directory and parse dash.conf
/// - Do not call GetDataDir(true) before this step finishes
/// - Do not call gArgs.GetDataDirNet(true) before this step finishes
if (!CheckDataDirOption()) {
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
QMessageBox::critical(nullptr, PACKAGE_NAME,
Expand Down
2 changes: 1 addition & 1 deletion src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ QString ClientModel::formatClientStartupTime() const

QString ClientModel::dataDir() const
{
return GUIUtil::boostPathToQString(GetDataDir());
return GUIUtil::boostPathToQString(gArgs.GetDataDirNet());
}

QString ClientModel::blocksDir() const
Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void handleCloseWindowShortcut(QWidget* w)

void openDebugLogfile()
{
fs::path pathDebug = GetDataDir() / "debug.log";
fs::path pathDebug = gArgs.GetDataDirNet() / "debug.log";

/* Open debug.log with the associated application */
if (fs::exists(pathDebug))
Expand Down
2 changes: 1 addition & 1 deletion src/qt/intro.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Intro : public QDialog
* @returns true if a data directory was selected, false if the user cancelled the selection
* dialog.
*
* @note do NOT call global GetDataDir() before calling this function, this
* @note do NOT call global gArgs.GetDataDirNet() before calling this function, this
* will cause the wrong path to be cached.
*/
static bool showIfNeeded(bool& did_show_intro, bool& prune);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void OptionsModel::Reset()
QSettings settings;

// Backup old settings to chain-specific datadir for troubleshooting
BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings);
BackupSettings(gArgs.GetDataDirNet() / "guisettings.ini.bak", settings);

// Save the strDataDir setting
QString dataDir = GUIUtil::getDefaultDataDirectory();
Expand Down
4 changes: 2 additions & 2 deletions src/qt/paymentserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ static QString ipcServerName()
QString name("DashQt");

// Append a simple hash of the datadir
// Note that GetDataDir(true) returns a different path
// Note that gArgs.GetDataDirNet() returns a different path
// for -testnet versus main net
QString ddir(GUIUtil::boostPathToQString(GetDataDir(true)));
QString ddir(GUIUtil::boostPathToQString(gArgs.GetDataDirNet()));
name.append(QString::number(qHash(ddir)));

return name;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/test/apptests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void AppTests::appTests()

fs::create_directories([] {
BasicTestingSetup test{CBaseChainParams::REGTEST}; // Create a temp data directory to backup the gui settings to
return GetDataDir() / "blocks";
return gArgs.GetDataDirNet() / "blocks";
}());

qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2879,10 +2879,10 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
}
}.Check(request);

const fs::path path = fsbridge::AbsPathJoin(GetDataDir(), request.params[0].get_str());
const fs::path path = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), request.params[0].get_str());
// Write to a temporary path and then move into `path` on completion
// to avoid confusion due to an interruption.
const fs::path temppath = fsbridge::AbsPathJoin(GetDataDir(), request.params[0].get_str() + ".incomplete");
const fs::path temppath = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), request.params[0].get_str() + ".incomplete");

if (fs::exists(path)) {
throw JSONRPCError(
Expand Down
18 changes: 9 additions & 9 deletions src/test/dbwrapper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
{
// Perform tests both obfuscated and non-obfuscated.
for (const bool obfuscate : {false, true}) {
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_obfuscate_true" : "dbwrapper_obfuscate_false");
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_obfuscate_true" : "dbwrapper_obfuscate_false");
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
char key = 'k';
uint256 in = InsecureRand256();
Expand All @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_basic_data)
{
// Perform tests both obfuscated and non-obfuscated.
for (bool obfuscate : {false, true}) {
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_1_obfuscate_true" : "dbwrapper_1_obfuscate_false");
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_1_obfuscate_true" : "dbwrapper_1_obfuscate_false");
CDBWrapper dbw(ph, (1 << 20), false, true, obfuscate);

uint256 res;
Expand Down Expand Up @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
{
// Perform tests both obfuscated and non-obfuscated.
for (const bool obfuscate : {false, true}) {
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);

char key = 'i';
Expand Down Expand Up @@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
{
// Perform tests both obfuscated and non-obfuscated.
for (const bool obfuscate : {false, true}) {
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);

// The two keys are intentionally chosen for ordering
Expand Down Expand Up @@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
{
// We're going to share this fs::path between two wrappers
fs::path ph = m_args.GetDataDirPath() / "existing_data_no_obfuscate";
fs::path ph = m_args.GetDataDirBase() / "existing_data_no_obfuscate";
create_directories(ph);

// Set up a non-obfuscated wrapper to write some initial data.
Expand Down Expand Up @@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
BOOST_AUTO_TEST_CASE(existing_data_reindex)
{
// We're going to share this fs::path between two wrappers
fs::path ph = m_args.GetDataDirPath() / "existing_data_reindex";
fs::path ph = m_args.GetDataDirBase() / "existing_data_reindex";
create_directories(ph);

// Set up a non-obfuscated wrapper to write some initial data.
Expand Down Expand Up @@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)

BOOST_AUTO_TEST_CASE(iterator_ordering)
{
fs::path ph = m_args.GetDataDirPath() / "iterator_ordering";
fs::path ph = m_args.GetDataDirBase() / "iterator_ordering";
CDBWrapper dbw(ph, (1 << 20), true, false, false);
for (int x=0x00; x<256; ++x) {
uint8_t key = x;
Expand Down Expand Up @@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
{
char buf[10];

fs::path ph = m_args.GetDataDirPath() / "iterator_string_ordering";
fs::path ph = m_args.GetDataDirBase() / "iterator_string_ordering";
CDBWrapper dbw(ph, (1 << 20), true, false, false);
for (int x=0x00; x<10; ++x) {
for (int y = 0; y < 10; y++) {
Expand Down Expand Up @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(unicodepath)
// On Windows this test will fail if the directory is created using
// the ANSI CreateDirectoryA call and the code page isn't UTF8.
// It will succeed if created with CreateDirectoryW.
fs::path ph = m_args.GetDataDirPath() / "test_runner_₿_🏃_20191128_104644";
fs::path ph = m_args.GetDataDirBase() / "test_runner_₿_🏃_20191128_104644";
CDBWrapper dbw(ph, (1 << 20));

fs::path lockPath = ph / "LOCK";
Expand Down
6 changes: 3 additions & 3 deletions src/test/denialofservice_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
BOOST_AUTO_TEST_CASE(DoS_banning)
{
const CChainParams& chainparams = Params();
auto banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *governance, m_node.cj_ctx,
Expand Down Expand Up @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
BOOST_AUTO_TEST_CASE(DoS_banscore)
{
const CChainParams& chainparams = Params();
auto banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *governance, m_node.cj_ctx,
Expand Down Expand Up @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
BOOST_AUTO_TEST_CASE(DoS_bantime)
{
const CChainParams& chainparams = Params();
auto banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *governance, m_node.cj_ctx,
Expand Down
8 changes: 4 additions & 4 deletions src/test/flatfile_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BOOST_FIXTURE_TEST_SUITE(flatfile_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(flatfile_filename)
{
const auto data_dir = m_args.GetDataDirPath();
const auto data_dir = m_args.GetDataDirBase();

FlatFilePos pos(456, 789);

Expand All @@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(flatfile_filename)

BOOST_AUTO_TEST_CASE(flatfile_open)
{
const auto data_dir = m_args.GetDataDirPath();
const auto data_dir = m_args.GetDataDirBase();
FlatFileSeq seq(data_dir, "a", 16 * 1024);

std::string line1("A purely peer-to-peer version of electronic cash would allow online "
Expand Down Expand Up @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)

BOOST_AUTO_TEST_CASE(flatfile_allocate)
{
const auto data_dir = m_args.GetDataDirPath();
const auto data_dir = m_args.GetDataDirBase();
FlatFileSeq seq(data_dir, "a", 100);

bool out_of_space;
Expand All @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(flatfile_allocate)

BOOST_AUTO_TEST_CASE(flatfile_flush)
{
const auto data_dir = m_args.GetDataDirPath();
const auto data_dir = m_args.GetDataDirBase();
FlatFileSeq seq(data_dir, "a", 100);

bool out_of_space;
Expand Down
2 changes: 1 addition & 1 deletion src/test/fs_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(fsbridge_fstream)
{
fs::path tmpfolder = m_args.GetDataDirPath();
fs::path tmpfolder = m_args.GetDataDirBase();
// tmpfile1 should be the same as tmpfile2
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
int limit_max_ops{300};
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
SetMockTime(ConsumeTime(fuzzed_data_provider));
fs::path banlist_file = GetDataDir() / "fuzzed_banlist";
fs::path banlist_file = gArgs.GetDataDirNet() / "fuzzed_banlist";

const bool start_with_corrupted_banlist{fuzzed_data_provider.ConsumeBool()};
bool force_read_and_write_to_err{false};
Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/i2p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FUZZ_TARGET_INIT(i2p, initialize_i2p)
const CService sam_proxy;
CThreadInterrupt interrupt;

i2p::sam::Session sess{GetDataDir() / "fuzzed_i2p_private_key", sam_proxy, &interrupt};
i2p::sam::Session sess{gArgs.GetDataDirNet() / "fuzzed_i2p_private_key", sam_proxy, &interrupt};

i2p::Connection conn;

Expand Down
2 changes: 1 addition & 1 deletion src/test/i2p_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(unlimited_recv)
};

CThreadInterrupt interrupt;
i2p::sam::Session session(GetDataDir() / "test_i2p_private_key", CService{}, &interrupt);
i2p::sam::Session session(gArgs.GetDataDirNet() / "test_i2p_private_key", CService{}, &interrupt);

{
ASSERT_DEBUG_LOG("Creating SAM session");
Expand Down

0 comments on commit 713bb68

Please sign in to comment.