Skip to content

Commit 94173f1

Browse files
committed
merge bitcoin#21850: Remove GetDataDir(net_specific) function
1 parent 6264c7b commit 94173f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+117
-107
lines changed

src/addrdb.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
5252
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
5353

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

173173
bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr)
174174
{
175-
const auto pathAddr = GetDataDir() / "peers.dat";
175+
const auto pathAddr = gArgs.GetDataDirNet() / "peers.dat";
176176
return SerializeFileDB("peers", pathAddr, addr, CLIENT_VERSION);
177177
}
178178

@@ -187,7 +187,7 @@ std::optional<bilingual_str> LoadAddrman(const std::vector<bool>& asmap, const A
187187
addrman = std::make_unique<AddrMan>(asmap, /* deterministic */ false, /* consistency_check_ratio */ check_addrman);
188188

189189
int64_t nStart = GetTimeMillis();
190-
const auto path_addr{GetDataDir() / "peers.dat"};
190+
const auto path_addr{gArgs.GetDataDirNet() / "peers.dat"};
191191
try {
192192
DeserializeFileDB(path_addr, *addrman, CLIENT_VERSION);
193193
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->size(), GetTimeMillis() - nStart);

src/coinjoin/client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_cha
137137
if (!CCoinJoinClientOptions::IsEnabled()) return;
138138
if (!m_mn_sync.IsBlockchainSynced()) return;
139139

140-
if (!CheckDiskSpace(GetDataDir())) {
140+
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
141141
ResetPool();
142142
StopMixing();
143143
WalletCJLogPrint(m_wallet, "CCoinJoinClientManager::ProcessMessage -- Not enough disk space, disabling CoinJoin.\n");
@@ -460,7 +460,7 @@ bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn,
460460
return false;
461461
}
462462

463-
if (!CheckDiskSpace(GetDataDir())) {
463+
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
464464
UnlockCoins();
465465
keyHolderStorage.ReturnAll();
466466
WITH_LOCK(cs_coinjoin, SetNull());

src/evo/evodb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void CEvoDBScopedCommitter::Rollback()
3232
}
3333

3434
CEvoDB::CEvoDB(size_t nCacheSize, bool fMemory, bool fWipe) :
35-
db(fMemory ? "" : (GetDataDir() / "evodb"), nCacheSize, fMemory, fWipe),
35+
db(fMemory ? "" : (gArgs.GetDataDirNet() / "evodb"), nCacheSize, fMemory, fWipe),
3636
rootBatch(db),
3737
rootDBTransaction(db, rootBatch),
3838
curDBTransaction(rootDBTransaction, rootDBTransaction)

src/flat-database.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class CFlatDB
180180
public:
181181
CFlatDB(std::string strFilenameIn, std::string strMagicMessageIn)
182182
{
183-
pathDB = GetDataDir() / strFilenameIn;
183+
pathDB = gArgs.GetDataDirNet() / strFilenameIn;
184184
strFilename = strFilenameIn;
185185
strMagicMessage = strMagicMessageIn;
186186
}

src/index/blockfilterindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
103103
const std::string& filter_name = BlockFilterTypeName(filter_type);
104104
if (filter_name.empty()) throw std::invalid_argument("unknown filter_type");
105105

106-
fs::path path = GetDataDir() / "indexes" / "blockfilter" / filter_name;
106+
fs::path path = gArgs.GetDataDirNet() / "indexes" / "blockfilter" / filter_name;
107107
fs::create_directories(path);
108108

109109
m_name = filter_name + " block filter index";

src/index/coinstatsindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ std::unique_ptr<CoinStatsIndex> g_coin_stats_index;
9898

9999
CoinStatsIndex::CoinStatsIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
100100
{
101-
fs::path path{GetDataDir() / "indexes" / "coinstats"};
101+
fs::path path{gArgs.GetDataDirNet() / "indexes" / "coinstats"};
102102
fs::create_directories(path);
103103

104104
m_db = std::make_unique<CoinStatsIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);

src/index/txindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TxIndex::DB : public BaseIndex::DB
3737
};
3838

3939
TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) :
40-
BaseIndex::DB(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
40+
BaseIndex::DB(gArgs.GetDataDirNet() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
4141
{}
4242

4343
bool TxIndex::DB::ReadTxPos(const uint256 &txid, CDiskTxPos& pos) const

src/init.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
13671367
static bool LockDataDirectory(bool probeOnly)
13681368
{
13691369
// Make sure only a single Dash Core process is using the data directory.
1370-
fs::path datadir = GetDataDir();
1370+
fs::path datadir = gArgs.GetDataDirNet();
13711371
if (!DirIsWritable(datadir)) {
13721372
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), datadir.string()));
13731373
}
@@ -1531,7 +1531,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15311531
asmap_path = DEFAULT_ASMAP_FILENAME;
15321532
}
15331533
if (!asmap_path.is_absolute()) {
1534-
asmap_path = GetDataDir() / asmap_path;
1534+
asmap_path = gArgs.GetDataDirNet() / asmap_path;
15351535
}
15361536
if (!fs::exists(asmap_path)) {
15371537
InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
@@ -1555,7 +1555,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15551555
}
15561556

15571557
assert(!node.banman);
1558-
node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
1558+
node.banman = std::make_unique<BanMan>(gArgs.GetDataDirNet() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
15591559
assert(!node.connman);
15601560
node.connman = std::make_unique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), *node.addrman, args.GetBoolArg("-networkactive", true));
15611561

@@ -1773,7 +1773,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17731773
// ********************************************************* Step 7a: Load sporks
17741774

17751775
if (!node.sporkman->LoadCache()) {
1776-
auto file_path = (GetDataDir() / "sporks.dat").string();
1776+
auto file_path = (gArgs.GetDataDirNet() / "sporks.dat").string();
17771777
return InitError(strprintf(_("Failed to load sporks cache from %s"), file_path));
17781778
}
17791779

@@ -2128,15 +2128,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
21282128
bool fLoadCacheFiles = !(fReindex || fReindexChainState) && (chainman.ActiveChain().Tip() != nullptr);
21292129

21302130
if (!node.netfulfilledman->LoadCache(fLoadCacheFiles)) {
2131-
auto file_path = (GetDataDir() / "netfulfilled.dat").string();
2131+
auto file_path = (gArgs.GetDataDirNet() / "netfulfilled.dat").string();
21322132
if (fLoadCacheFiles) {
21332133
return InitError(strprintf(_("Failed to load fulfilled requests cache from %s"), file_path));
21342134
}
21352135
return InitError(strprintf(_("Failed to clear fulfilled requests cache at %s"), file_path));
21362136
}
21372137

21382138
if (!node.mn_metaman->LoadCache(fLoadCacheFiles)) {
2139-
auto file_path = (GetDataDir() / "mncache.dat").string();
2139+
auto file_path = (gArgs.GetDataDirNet() / "mncache.dat").string();
21402140
if (fLoadCacheFiles) {
21412141
return InitError(strprintf(_("Failed to load masternode cache from %s"), file_path));
21422142
}
@@ -2145,7 +2145,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
21452145

21462146
if (is_governance_enabled) {
21472147
if (!node.govman->LoadCache(fLoadCacheFiles)) {
2148-
auto file_path = (GetDataDir() / "governance.dat").string();
2148+
auto file_path = (gArgs.GetDataDirNet() / "governance.dat").string();
21492149
if (fLoadCacheFiles) {
21502150
return InitError(strprintf(_("Failed to load governance cache from %s"), file_path));
21512151
}
@@ -2242,8 +2242,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
22422242

22432243
// ********************************************************* Step 11: import blocks
22442244

2245-
if (!CheckDiskSpace(GetDataDir())) {
2246-
InitError(strprintf(_("Error: Disk space is low for %s"), GetDataDir()));
2245+
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
2246+
InitError(strprintf(_("Error: Disk space is low for %s"), gArgs.GetDataDirNet()));
22472247
return false;
22482248
}
22492249
if (!CheckDiskSpace(gArgs.GetBlocksDirPath())) {

src/init/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool StartLogging(const ArgsManager& args)
131131
if (!LogInstance().m_log_timestamps)
132132
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
133133
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
134-
LogPrintf("Using data directory %s\n", GetDataDir().string());
134+
LogPrintf("Using data directory %s\n", gArgs.GetDataDirNet().string());
135135

136136
// Only log conf file usage message if conf file actually exists.
137137
fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME));

src/llmq/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
4343
{
4444
// NOTE: we use this only to wipe the old db, do NOT use it for anything else
4545
// TODO: remove it in some future version
46-
auto llmqDbTmp = std::make_unique<CDBWrapper>(unit_tests ? "" : (GetDataDir() / "llmq"), 1 << 20, unit_tests, true);
46+
auto llmqDbTmp = std::make_unique<CDBWrapper>(unit_tests ? "" : (gArgs.GetDataDirNet() / "llmq"), 1 << 20, unit_tests, true);
4747
}
4848

4949
LLMQContext::~LLMQContext() {

0 commit comments

Comments
 (0)