mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
merge bitcoin#21850: Remove GetDataDir(net_specific)
function
This commit is contained in:
parent
6264c7b7c7
commit
94173f14dd
@ -52,7 +52,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
|
|||||||
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
|
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
|
||||||
|
|
||||||
// open temp output file, and associate with CAutoFile
|
// 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");
|
FILE *file = fsbridge::fopen(pathTmp, "wb");
|
||||||
CAutoFile fileout(file, SER_DISK, version);
|
CAutoFile fileout(file, SER_DISK, version);
|
||||||
if (fileout.IsNull()) {
|
if (fileout.IsNull()) {
|
||||||
@ -172,7 +172,7 @@ bool CBanDB::Read(banmap_t& banSet)
|
|||||||
|
|
||||||
bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr)
|
bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr)
|
||||||
{
|
{
|
||||||
const auto pathAddr = GetDataDir() / "peers.dat";
|
const auto pathAddr = gArgs.GetDataDirNet() / "peers.dat";
|
||||||
return SerializeFileDB("peers", pathAddr, addr, CLIENT_VERSION);
|
return SerializeFileDB("peers", pathAddr, addr, CLIENT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ std::optional<bilingual_str> LoadAddrman(const std::vector<bool>& asmap, const A
|
|||||||
addrman = std::make_unique<AddrMan>(asmap, /* deterministic */ false, /* consistency_check_ratio */ check_addrman);
|
addrman = std::make_unique<AddrMan>(asmap, /* deterministic */ false, /* consistency_check_ratio */ check_addrman);
|
||||||
|
|
||||||
int64_t nStart = GetTimeMillis();
|
int64_t nStart = GetTimeMillis();
|
||||||
const auto path_addr{GetDataDir() / "peers.dat"};
|
const auto path_addr{gArgs.GetDataDirNet() / "peers.dat"};
|
||||||
try {
|
try {
|
||||||
DeserializeFileDB(path_addr, *addrman, CLIENT_VERSION);
|
DeserializeFileDB(path_addr, *addrman, CLIENT_VERSION);
|
||||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->size(), GetTimeMillis() - nStart);
|
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman->size(), GetTimeMillis() - nStart);
|
||||||
|
@ -137,7 +137,7 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_cha
|
|||||||
if (!CCoinJoinClientOptions::IsEnabled()) return;
|
if (!CCoinJoinClientOptions::IsEnabled()) return;
|
||||||
if (!m_mn_sync.IsBlockchainSynced()) return;
|
if (!m_mn_sync.IsBlockchainSynced()) return;
|
||||||
|
|
||||||
if (!CheckDiskSpace(GetDataDir())) {
|
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
|
||||||
ResetPool();
|
ResetPool();
|
||||||
StopMixing();
|
StopMixing();
|
||||||
WalletCJLogPrint(m_wallet, "CCoinJoinClientManager::ProcessMessage -- Not enough disk space, disabling CoinJoin.\n");
|
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,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckDiskSpace(GetDataDir())) {
|
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
|
||||||
UnlockCoins();
|
UnlockCoins();
|
||||||
keyHolderStorage.ReturnAll();
|
keyHolderStorage.ReturnAll();
|
||||||
WITH_LOCK(cs_coinjoin, SetNull());
|
WITH_LOCK(cs_coinjoin, SetNull());
|
||||||
|
@ -32,7 +32,7 @@ void CEvoDBScopedCommitter::Rollback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CEvoDB::CEvoDB(size_t nCacheSize, bool fMemory, bool fWipe) :
|
CEvoDB::CEvoDB(size_t nCacheSize, bool fMemory, bool fWipe) :
|
||||||
db(fMemory ? "" : (GetDataDir() / "evodb"), nCacheSize, fMemory, fWipe),
|
db(fMemory ? "" : (gArgs.GetDataDirNet() / "evodb"), nCacheSize, fMemory, fWipe),
|
||||||
rootBatch(db),
|
rootBatch(db),
|
||||||
rootDBTransaction(db, rootBatch),
|
rootDBTransaction(db, rootBatch),
|
||||||
curDBTransaction(rootDBTransaction, rootDBTransaction)
|
curDBTransaction(rootDBTransaction, rootDBTransaction)
|
||||||
|
@ -180,7 +180,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CFlatDB(std::string strFilenameIn, std::string strMagicMessageIn)
|
CFlatDB(std::string strFilenameIn, std::string strMagicMessageIn)
|
||||||
{
|
{
|
||||||
pathDB = GetDataDir() / strFilenameIn;
|
pathDB = gArgs.GetDataDirNet() / strFilenameIn;
|
||||||
strFilename = strFilenameIn;
|
strFilename = strFilenameIn;
|
||||||
strMagicMessage = strMagicMessageIn;
|
strMagicMessage = strMagicMessageIn;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type,
|
|||||||
const std::string& filter_name = BlockFilterTypeName(filter_type);
|
const std::string& filter_name = BlockFilterTypeName(filter_type);
|
||||||
if (filter_name.empty()) throw std::invalid_argument("unknown 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);
|
fs::create_directories(path);
|
||||||
|
|
||||||
m_name = filter_name + " block filter index";
|
m_name = filter_name + " block filter index";
|
||||||
|
@ -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)
|
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);
|
fs::create_directories(path);
|
||||||
|
|
||||||
m_db = std::make_unique<CoinStatsIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
|
m_db = std::make_unique<CoinStatsIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) :
|
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
|
bool TxIndex::DB::ReadTxPos(const uint256 &txid, CDiskTxPos& pos) const
|
||||||
|
18
src/init.cpp
18
src/init.cpp
@ -1367,7 +1367,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
|||||||
static bool LockDataDirectory(bool probeOnly)
|
static bool LockDataDirectory(bool probeOnly)
|
||||||
{
|
{
|
||||||
// Make sure only a single Dash Core process is using the data directory.
|
// 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)) {
|
if (!DirIsWritable(datadir)) {
|
||||||
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), datadir.string()));
|
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), datadir.string()));
|
||||||
}
|
}
|
||||||
@ -1531,7 +1531,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
asmap_path = DEFAULT_ASMAP_FILENAME;
|
asmap_path = DEFAULT_ASMAP_FILENAME;
|
||||||
}
|
}
|
||||||
if (!asmap_path.is_absolute()) {
|
if (!asmap_path.is_absolute()) {
|
||||||
asmap_path = GetDataDir() / asmap_path;
|
asmap_path = gArgs.GetDataDirNet() / asmap_path;
|
||||||
}
|
}
|
||||||
if (!fs::exists(asmap_path)) {
|
if (!fs::exists(asmap_path)) {
|
||||||
InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
|
InitError(strprintf(_("Could not find asmap file %s"), asmap_path));
|
||||||
@ -1555,7 +1555,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(!node.banman);
|
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);
|
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, args.GetBoolArg("-networkactive", true));
|
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));
|
||||||
|
|
||||||
@ -1773,7 +1773,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
// ********************************************************* Step 7a: Load sporks
|
// ********************************************************* Step 7a: Load sporks
|
||||||
|
|
||||||
if (!node.sporkman->LoadCache()) {
|
if (!node.sporkman->LoadCache()) {
|
||||||
auto file_path = (GetDataDir() / "sporks.dat").string();
|
auto file_path = (gArgs.GetDataDirNet() / "sporks.dat").string();
|
||||||
return InitError(strprintf(_("Failed to load sporks cache from %s"), file_path));
|
return InitError(strprintf(_("Failed to load sporks cache from %s"), file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2128,7 +2128,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
bool fLoadCacheFiles = !(fReindex || fReindexChainState) && (chainman.ActiveChain().Tip() != nullptr);
|
bool fLoadCacheFiles = !(fReindex || fReindexChainState) && (chainman.ActiveChain().Tip() != nullptr);
|
||||||
|
|
||||||
if (!node.netfulfilledman->LoadCache(fLoadCacheFiles)) {
|
if (!node.netfulfilledman->LoadCache(fLoadCacheFiles)) {
|
||||||
auto file_path = (GetDataDir() / "netfulfilled.dat").string();
|
auto file_path = (gArgs.GetDataDirNet() / "netfulfilled.dat").string();
|
||||||
if (fLoadCacheFiles) {
|
if (fLoadCacheFiles) {
|
||||||
return InitError(strprintf(_("Failed to load fulfilled requests cache from %s"), file_path));
|
return InitError(strprintf(_("Failed to load fulfilled requests cache from %s"), file_path));
|
||||||
}
|
}
|
||||||
@ -2136,7 +2136,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!node.mn_metaman->LoadCache(fLoadCacheFiles)) {
|
if (!node.mn_metaman->LoadCache(fLoadCacheFiles)) {
|
||||||
auto file_path = (GetDataDir() / "mncache.dat").string();
|
auto file_path = (gArgs.GetDataDirNet() / "mncache.dat").string();
|
||||||
if (fLoadCacheFiles) {
|
if (fLoadCacheFiles) {
|
||||||
return InitError(strprintf(_("Failed to load masternode cache from %s"), file_path));
|
return InitError(strprintf(_("Failed to load masternode cache from %s"), file_path));
|
||||||
}
|
}
|
||||||
@ -2145,7 +2145,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
|
|
||||||
if (is_governance_enabled) {
|
if (is_governance_enabled) {
|
||||||
if (!node.govman->LoadCache(fLoadCacheFiles)) {
|
if (!node.govman->LoadCache(fLoadCacheFiles)) {
|
||||||
auto file_path = (GetDataDir() / "governance.dat").string();
|
auto file_path = (gArgs.GetDataDirNet() / "governance.dat").string();
|
||||||
if (fLoadCacheFiles) {
|
if (fLoadCacheFiles) {
|
||||||
return InitError(strprintf(_("Failed to load governance cache from %s"), file_path));
|
return InitError(strprintf(_("Failed to load governance cache from %s"), file_path));
|
||||||
}
|
}
|
||||||
@ -2242,8 +2242,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
|
|
||||||
// ********************************************************* Step 11: import blocks
|
// ********************************************************* Step 11: import blocks
|
||||||
|
|
||||||
if (!CheckDiskSpace(GetDataDir())) {
|
if (!CheckDiskSpace(gArgs.GetDataDirNet())) {
|
||||||
InitError(strprintf(_("Error: Disk space is low for %s"), GetDataDir()));
|
InitError(strprintf(_("Error: Disk space is low for %s"), gArgs.GetDataDirNet()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!CheckDiskSpace(gArgs.GetBlocksDirPath())) {
|
if (!CheckDiskSpace(gArgs.GetBlocksDirPath())) {
|
||||||
|
@ -131,7 +131,7 @@ bool StartLogging(const ArgsManager& args)
|
|||||||
if (!LogInstance().m_log_timestamps)
|
if (!LogInstance().m_log_timestamps)
|
||||||
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
|
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
|
||||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
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.
|
// Only log conf file usage message if conf file actually exists.
|
||||||
fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME));
|
fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME));
|
||||||
|
@ -43,7 +43,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
|||||||
{
|
{
|
||||||
// NOTE: we use this only to wipe the old db, do NOT use it for anything else
|
// NOTE: we use this only to wipe the old db, do NOT use it for anything else
|
||||||
// TODO: remove it in some future version
|
// TODO: remove it in some future version
|
||||||
auto llmqDbTmp = std::make_unique<CDBWrapper>(unit_tests ? "" : (GetDataDir() / "llmq"), 1 << 20, unit_tests, true);
|
auto llmqDbTmp = std::make_unique<CDBWrapper>(unit_tests ? "" : (gArgs.GetDataDirNet() / "llmq"), 1 << 20, unit_tests, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLMQContext::~LLMQContext() {
|
LLMQContext::~LLMQContext() {
|
||||||
|
@ -28,7 +28,7 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai
|
|||||||
CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman, CQuorumBlockProcessor& _quorumBlockProcessor,
|
CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman,
|
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman,
|
||||||
const std::unique_ptr<PeerManager>& peerman, bool unitTests, bool fWipe) :
|
const std::unique_ptr<PeerManager>& peerman, bool unitTests, bool fWipe) :
|
||||||
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
|
db(std::make_unique<CDBWrapper>(unitTests ? "" : (gArgs.GetDataDirNet() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
@ -63,7 +63,7 @@ void CDKGSessionManager::MigrateDKG()
|
|||||||
LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- start\n", __func__);
|
LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- start\n", __func__);
|
||||||
|
|
||||||
CDBBatch batch(*db);
|
CDBBatch batch(*db);
|
||||||
auto oldDb = std::make_unique<CDBWrapper>(GetDataDir() / "llmq", 8 << 20);
|
auto oldDb = std::make_unique<CDBWrapper>(gArgs.GetDataDirNet() / "llmq", 8 << 20);
|
||||||
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());
|
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());
|
||||||
|
|
||||||
auto start_vvec = std::make_tuple(DB_VVEC, (Consensus::LLMQType)0, uint256(), uint256());
|
auto start_vvec = std::make_tuple(DB_VVEC, (Consensus::LLMQType)0, uint256(), uint256());
|
||||||
|
@ -55,7 +55,7 @@ uint256 CInstantSendLock::GetRequestId() const
|
|||||||
|
|
||||||
|
|
||||||
CInstantSendDb::CInstantSendDb(bool unitTests, bool fWipe) :
|
CInstantSendDb::CInstantSendDb(bool unitTests, bool fWipe) :
|
||||||
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/isdb"), 32 << 20, unitTests, fWipe))
|
db(std::make_unique<CDBWrapper>(unitTests ? "" : (gArgs.GetDataDirNet() / "llmq/isdb"), 32 << 20, unitTests, fWipe))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ UniValue CRecoveredSig::ToJson() const
|
|||||||
|
|
||||||
|
|
||||||
CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory, bool fWipe) :
|
CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory, bool fWipe) :
|
||||||
db(std::make_unique<CDBWrapper>(fMemory ? "" : (GetDataDir() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe))
|
db(std::make_unique<CDBWrapper>(fMemory ? "" : (gArgs.GetDataDirNet() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe))
|
||||||
{
|
{
|
||||||
MigrateRecoveredSigs();
|
MigrateRecoveredSigs();
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ void CRecoveredSigsDb::MigrateRecoveredSigs()
|
|||||||
LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- start\n", __func__);
|
LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- start\n", __func__);
|
||||||
|
|
||||||
CDBBatch batch(*db);
|
CDBBatch batch(*db);
|
||||||
auto oldDb = std::make_unique<CDBWrapper>(GetDataDir() / "llmq", 8 << 20);
|
auto oldDb = std::make_unique<CDBWrapper>(gArgs.GetDataDirNet() / "llmq", 8 << 20);
|
||||||
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());
|
std::unique_ptr<CDBIterator> pcursor(oldDb->NewIterator());
|
||||||
|
|
||||||
auto start_h = std::make_tuple(std::string("rs_h"), uint256());
|
auto start_h = std::make_tuple(std::string("rs_h"), uint256());
|
||||||
|
@ -3469,7 +3469,7 @@ bool CConnman::Start(CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_met
|
|||||||
|
|
||||||
Proxy i2p_sam;
|
Proxy i2p_sam;
|
||||||
if (GetProxy(NET_I2P, i2p_sam) && connOptions.m_i2p_accept_incoming) {
|
if (GetProxy(NET_I2P, i2p_sam) && connOptions.m_i2p_accept_incoming) {
|
||||||
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);
|
i2p_sam.proxy, &interruptNet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3479,7 +3479,7 @@ bool CConnman::Start(CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_met
|
|||||||
|
|
||||||
if (m_use_addrman_outgoing) {
|
if (m_use_addrman_outgoing) {
|
||||||
// Load addresses from anchors.dat
|
// 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) {
|
if (m_anchors.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
|
||||||
m_anchors.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
|
m_anchors.resize(MAX_BLOCK_RELAY_ONLY_ANCHORS);
|
||||||
}
|
}
|
||||||
@ -3642,7 +3642,7 @@ void CConnman::StopNodes()
|
|||||||
if (anchors_to_dump.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
|
if (anchors_to_dump.size() > MAX_BLOCK_RELAY_ONLY_ANCHORS) {
|
||||||
anchors_to_dump.resize(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4313,7 +4313,7 @@ void CaptureMessageToFile(const CAddress& addr,
|
|||||||
std::string clean_addr = addr.ToString();
|
std::string clean_addr = addr.ToString();
|
||||||
std::replace(clean_addr.begin(), clean_addr.end(), ':', '_');
|
std::replace(clean_addr.begin(), clean_addr.end(), ':', '_');
|
||||||
|
|
||||||
fs::path base_path = GetDataDir() / "message_capture" / clean_addr;
|
fs::path base_path = gArgs.GetDataDirNet() / "message_capture" / clean_addr;
|
||||||
fs::create_directories(base_path);
|
fs::create_directories(base_path);
|
||||||
|
|
||||||
fs::path path = base_path / (is_incoming ? "msgs_recv.dat" : "msgs_sent.dat");
|
fs::path path = base_path / (is_incoming ? "msgs_recv.dat" : "msgs_sent.dat");
|
||||||
|
@ -530,7 +530,7 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
|
|||||||
longStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE);
|
longStats = std::make_unique<TxConfirmStats>(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE);
|
||||||
|
|
||||||
// If the fee estimation file is present, read recorded estimations
|
// 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);
|
CAutoFile est_file(fsbridge::fopen(est_filepath, "rb"), SER_DISK, CLIENT_VERSION);
|
||||||
if (est_file.IsNull() || !Read(est_file)) {
|
if (est_file.IsNull() || !Read(est_file)) {
|
||||||
LogPrintf("Failed to read fee estimates from %s. Continue anyway.\n", est_filepath.string());
|
LogPrintf("Failed to read fee estimates from %s. Continue anyway.\n", est_filepath.string());
|
||||||
@ -890,7 +890,7 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation
|
|||||||
void CBlockPolicyEstimator::Flush() {
|
void CBlockPolicyEstimator::Flush() {
|
||||||
FlushUnconfirmed();
|
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);
|
CAutoFile est_file(fsbridge::fopen(est_filepath, "wb"), SER_DISK, CLIENT_VERSION);
|
||||||
if (est_file.IsNull() || !Write(est_file)) {
|
if (est_file.IsNull() || !Write(est_file)) {
|
||||||
LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", est_filepath.string());
|
LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", est_filepath.string());
|
||||||
|
@ -631,7 +631,7 @@ int GuiMain(int argc, char* argv[])
|
|||||||
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
|
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
|
||||||
|
|
||||||
/// 6. Determine availability of data directory and parse dash.conf
|
/// 6. Determine availability of data directory and parse dash.conf
|
||||||
/// - Do not call GetDataDir(true) before this step finishes
|
/// - Do not call gArgs.GetDataDirNet() before this step finishes
|
||||||
if (!CheckDataDirOption()) {
|
if (!CheckDataDirOption()) {
|
||||||
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
|
@ -246,7 +246,7 @@ QString ClientModel::formatClientStartupTime() const
|
|||||||
|
|
||||||
QString ClientModel::dataDir() const
|
QString ClientModel::dataDir() const
|
||||||
{
|
{
|
||||||
return GUIUtil::PathToQString(GetDataDir());
|
return GUIUtil::PathToQString(gArgs.GetDataDirNet());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClientModel::blocksDir() const
|
QString ClientModel::blocksDir() const
|
||||||
|
@ -634,7 +634,7 @@ void handleCloseWindowShortcut(QWidget* w)
|
|||||||
|
|
||||||
void openDebugLogfile()
|
void openDebugLogfile()
|
||||||
{
|
{
|
||||||
fs::path pathDebug = GetDataDir() / "debug.log";
|
fs::path pathDebug = gArgs.GetDataDirNet() / "debug.log";
|
||||||
|
|
||||||
/* Open debug.log with the associated application */
|
/* Open debug.log with the associated application */
|
||||||
if (fs::exists(pathDebug))
|
if (fs::exists(pathDebug))
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
* @returns true if a data directory was selected, false if the user cancelled the selection
|
* @returns true if a data directory was selected, false if the user cancelled the selection
|
||||||
* dialog.
|
* 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.
|
* will cause the wrong path to be cached.
|
||||||
*/
|
*/
|
||||||
static bool showIfNeeded(bool& did_show_intro, int64_t& prune_MiB);
|
static bool showIfNeeded(bool& did_show_intro, int64_t& prune_MiB);
|
||||||
|
@ -326,7 +326,7 @@ void OptionsModel::Reset()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// Backup old settings to chain-specific datadir for troubleshooting
|
// 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
|
// Save the strDataDir setting
|
||||||
QString dataDir = GUIUtil::getDefaultDataDirectory();
|
QString dataDir = GUIUtil::getDefaultDataDirectory();
|
||||||
|
@ -50,9 +50,9 @@ static QString ipcServerName()
|
|||||||
QString name("DashQt");
|
QString name("DashQt");
|
||||||
|
|
||||||
// Append a simple hash of the datadir
|
// 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
|
// for -testnet versus main net
|
||||||
QString ddir(GUIUtil::PathToQString(GetDataDir(true)));
|
QString ddir(GUIUtil::PathToQString(gArgs.GetDataDirNet()));
|
||||||
name.append(QString::number(qHash(ddir)));
|
name.append(QString::number(qHash(ddir)));
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -65,7 +65,7 @@ void AppTests::appTests()
|
|||||||
|
|
||||||
fs::create_directories([] {
|
fs::create_directories([] {
|
||||||
BasicTestingSetup test{CBaseChainParams::REGTEST}; // Create a temp data directory to backup the gui settings to
|
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");
|
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
|
||||||
|
@ -2960,10 +2960,10 @@ static RPCHelpMan dumptxoutset()
|
|||||||
},
|
},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
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
|
// Write to a temporary path and then move into `path` on completion
|
||||||
// to avoid confusion due to an interruption.
|
// 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)) {
|
if (fs::exists(path)) {
|
||||||
throw JSONRPCError(
|
throw JSONRPCError(
|
||||||
|
@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
|
|||||||
{
|
{
|
||||||
// Perform tests both obfuscated and non-obfuscated.
|
// Perform tests both obfuscated and non-obfuscated.
|
||||||
for (const bool obfuscate : {false, true}) {
|
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);
|
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||||
uint8_t key{'k'};
|
uint8_t key{'k'};
|
||||||
uint256 in = InsecureRand256();
|
uint256 in = InsecureRand256();
|
||||||
@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_basic_data)
|
|||||||
{
|
{
|
||||||
// Perform tests both obfuscated and non-obfuscated.
|
// Perform tests both obfuscated and non-obfuscated.
|
||||||
for (bool obfuscate : {false, true}) {
|
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);
|
CDBWrapper dbw(ph, (1 << 20), false, true, obfuscate);
|
||||||
|
|
||||||
uint256 res;
|
uint256 res;
|
||||||
@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
|||||||
{
|
{
|
||||||
// Perform tests both obfuscated and non-obfuscated.
|
// Perform tests both obfuscated and non-obfuscated.
|
||||||
for (const bool obfuscate : {false, true}) {
|
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);
|
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||||
|
|
||||||
uint8_t key{'i'};
|
uint8_t key{'i'};
|
||||||
@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
|||||||
{
|
{
|
||||||
// Perform tests both obfuscated and non-obfuscated.
|
// Perform tests both obfuscated and non-obfuscated.
|
||||||
for (const bool obfuscate : {false, true}) {
|
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);
|
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||||
|
|
||||||
// The two keys are intentionally chosen for ordering
|
// The two keys are intentionally chosen for ordering
|
||||||
@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
|||||||
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||||
{
|
{
|
||||||
// We're going to share this fs::path between two wrappers
|
// 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);
|
create_directories(ph);
|
||||||
|
|
||||||
// Set up a non-obfuscated wrapper to write some initial data.
|
// Set up a non-obfuscated wrapper to write some initial data.
|
||||||
@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
|||||||
BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||||
{
|
{
|
||||||
// We're going to share this fs::path between two wrappers
|
// 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);
|
create_directories(ph);
|
||||||
|
|
||||||
// Set up a non-obfuscated wrapper to write some initial data.
|
// Set up a non-obfuscated wrapper to write some initial data.
|
||||||
@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(iterator_ordering)
|
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);
|
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||||
for (int x=0x00; x<256; ++x) {
|
for (int x=0x00; x<256; ++x) {
|
||||||
uint8_t key = x;
|
uint8_t key = x;
|
||||||
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
|
|||||||
{
|
{
|
||||||
char buf[10];
|
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);
|
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||||
for (int x=0x00; x<10; ++x) {
|
for (int x=0x00; x<10; ++x) {
|
||||||
for (int y = 0; y < 10; y++) {
|
for (int y = 0; y < 10; y++) {
|
||||||
@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(unicodepath)
|
|||||||
// On Windows this test will fail if the directory is created using
|
// On Windows this test will fail if the directory is created using
|
||||||
// the ANSI CreateDirectoryA call and the code page isn't UTF8.
|
// the ANSI CreateDirectoryA call and the code page isn't UTF8.
|
||||||
// It will succeed if created with CreateDirectoryW.
|
// 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));
|
CDBWrapper dbw(ph, (1 << 20));
|
||||||
|
|
||||||
fs::path lockPath = ph / "LOCK";
|
fs::path lockPath = ph / "LOCK";
|
||||||
|
@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(block_relay_only_eviction)
|
|||||||
BOOST_AUTO_TEST_CASE(peer_discouragement)
|
BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
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<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
|
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||||
@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
|||||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
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 connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
|
||||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
||||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||||
|
@ -14,7 +14,7 @@ BOOST_FIXTURE_TEST_SUITE(flatfile_tests, BasicTestingSetup)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(flatfile_filename)
|
BOOST_AUTO_TEST_CASE(flatfile_filename)
|
||||||
{
|
{
|
||||||
const auto data_dir = m_args.GetDataDirPath();
|
const auto data_dir = m_args.GetDataDirBase();
|
||||||
|
|
||||||
FlatFilePos pos(456, 789);
|
FlatFilePos pos(456, 789);
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(flatfile_filename)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(flatfile_open)
|
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);
|
FlatFileSeq seq(data_dir, "a", 16 * 1024);
|
||||||
|
|
||||||
std::string line1("A purely peer-to-peer version of electronic cash would allow online "
|
std::string line1("A purely peer-to-peer version of electronic cash would allow online "
|
||||||
@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(flatfile_allocate)
|
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);
|
FlatFileSeq seq(data_dir, "a", 100);
|
||||||
|
|
||||||
bool out_of_space;
|
bool out_of_space;
|
||||||
@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(flatfile_allocate)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(flatfile_flush)
|
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);
|
FlatFileSeq seq(data_dir, "a", 100);
|
||||||
|
|
||||||
bool out_of_space;
|
bool out_of_space;
|
||||||
|
@ -13,7 +13,7 @@ BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(fsbridge_fstream)
|
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
|
// tmpfile1 should be the same as tmpfile2
|
||||||
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
|
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
|
||||||
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
|
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
|
||||||
|
@ -43,7 +43,7 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
|
|||||||
{
|
{
|
||||||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
|
||||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
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()};
|
const bool start_with_corrupted_banlist{fuzzed_data_provider.ConsumeBool()};
|
||||||
bool force_read_and_write_to_err{false};
|
bool force_read_and_write_to_err{false};
|
||||||
|
@ -30,7 +30,7 @@ FUZZ_TARGET_INIT(i2p, initialize_i2p)
|
|||||||
const CService sam_proxy;
|
const CService sam_proxy;
|
||||||
CThreadInterrupt interrupt;
|
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;
|
i2p::Connection conn;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ FUZZ_TARGET_INIT(utxo_snapshot, initialize_chain)
|
|||||||
const auto& node = setup->m_node;
|
const auto& node = setup->m_node;
|
||||||
auto& chainman{*node.chainman};
|
auto& chainman{*node.chainman};
|
||||||
|
|
||||||
const auto snapshot_path = GetDataDir() / "fuzzed_snapshot.dat";
|
const auto snapshot_path = gArgs.GetDataDirNet() / "fuzzed_snapshot.dat";
|
||||||
|
|
||||||
Assert(!chainman.SnapshotBlockhash());
|
Assert(!chainman.SnapshotBlockhash());
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(unlimited_recv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
CThreadInterrupt interrupt;
|
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 persistent SAM session");
|
ASSERT_DEBUG_LOG("Creating persistent SAM session");
|
||||||
|
@ -45,7 +45,7 @@ BOOST_FIXTURE_TEST_SUITE(settings_tests, BasicTestingSetup)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(ReadWrite)
|
BOOST_AUTO_TEST_CASE(ReadWrite)
|
||||||
{
|
{
|
||||||
fs::path path = m_args.GetDataDirPath() / "settings.json";
|
fs::path path = m_args.GetDataDirBase() / "settings.json";
|
||||||
|
|
||||||
WriteText(path, R"({
|
WriteText(path, R"({
|
||||||
"string": "string",
|
"string": "string",
|
||||||
|
@ -279,7 +279,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
|||||||
throw std::runtime_error("LoadGenesisBlock failed.");
|
throw std::runtime_error("LoadGenesisBlock failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||||
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(),
|
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(),
|
||||||
*m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
*m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman,
|
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman,
|
||||||
|
@ -58,23 +58,23 @@ BOOST_AUTO_TEST_CASE(util_datadir)
|
|||||||
ArgsManager args;
|
ArgsManager args;
|
||||||
args.ForceSetArg("-datadir", m_path_root.string());
|
args.ForceSetArg("-datadir", m_path_root.string());
|
||||||
|
|
||||||
const fs::path dd_norm = args.GetDataDirPath();
|
const fs::path dd_norm = args.GetDataDirBase();
|
||||||
|
|
||||||
args.ForceSetArg("-datadir", dd_norm.string() + "/");
|
args.ForceSetArg("-datadir", dd_norm.string() + "/");
|
||||||
args.ClearPathCache();
|
args.ClearPathCache();
|
||||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||||
|
|
||||||
args.ForceSetArg("-datadir", dd_norm.string() + "/.");
|
args.ForceSetArg("-datadir", dd_norm.string() + "/.");
|
||||||
args.ClearPathCache();
|
args.ClearPathCache();
|
||||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||||
|
|
||||||
args.ForceSetArg("-datadir", dd_norm.string() + "/./");
|
args.ForceSetArg("-datadir", dd_norm.string() + "/./");
|
||||||
args.ClearPathCache();
|
args.ClearPathCache();
|
||||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||||
|
|
||||||
args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
|
args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
|
||||||
args.ClearPathCache();
|
args.ClearPathCache();
|
||||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -1272,10 +1272,10 @@ BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
|
|||||||
// Test error logging, and remove previously written setting.
|
// Test error logging, and remove previously written setting.
|
||||||
{
|
{
|
||||||
ASSERT_DEBUG_LOG("Failed renaming settings file");
|
ASSERT_DEBUG_LOG("Failed renaming settings file");
|
||||||
fs::remove(args1.GetDataDirPath() / "settings.json");
|
fs::remove(args1.GetDataDirBase() / "settings.json");
|
||||||
fs::create_directory(args1.GetDataDirPath() / "settings.json");
|
fs::create_directory(args1.GetDataDirBase() / "settings.json");
|
||||||
args2.WriteSettingsFile();
|
args2.WriteSettingsFile();
|
||||||
fs::remove(args1.GetDataDirPath() / "settings.json");
|
fs::remove(args1.GetDataDirBase() / "settings.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2085,7 +2085,7 @@ static constexpr char ExitCommand = 'X';
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
||||||
{
|
{
|
||||||
fs::path dirname = m_args.GetDataDirPath() / "lock_dir";
|
fs::path dirname = m_args.GetDataDirBase() / "lock_dir";
|
||||||
const std::string lockname = ".lock";
|
const std::string lockname = ".lock";
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
// Revert SIGCHLD to default, otherwise boost.test will catch and fail on
|
// Revert SIGCHLD to default, otherwise boost.test will catch and fail on
|
||||||
@ -2174,7 +2174,7 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
|||||||
BOOST_AUTO_TEST_CASE(test_DirIsWritable)
|
BOOST_AUTO_TEST_CASE(test_DirIsWritable)
|
||||||
{
|
{
|
||||||
// Should be able to write to the data dir.
|
// Should be able to write to the data dir.
|
||||||
fs::path tmpdirname = m_args.GetDataDirPath();
|
fs::path tmpdirname = m_args.GetDataDirBase();
|
||||||
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
|
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
|
||||||
|
|
||||||
// Should not be able to write to a non-existent dir.
|
// Should not be able to write to a non-existent dir.
|
||||||
|
@ -584,7 +584,7 @@ void TorController::Reconnect()
|
|||||||
|
|
||||||
fs::path TorController::GetPrivateKeyFile()
|
fs::path TorController::GetPrivateKeyFile()
|
||||||
{
|
{
|
||||||
return GetDataDir() / "onion_v3_private_key";
|
return gArgs.GetDataDirNet() / "onion_v3_private_key";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg)
|
void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg)
|
||||||
|
@ -150,7 +150,7 @@ size_t CCoinsViewDB::EstimateSize() const
|
|||||||
return m_db->EstimateSize(DB_COIN, uint8_t(DB_COIN + 1));
|
return m_db->EstimateSize(DB_COIN, uint8_t(DB_COIN + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
|
CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(gArgs.GetDataDirNet() / "blocks" / "index", nCacheSize, fMemory, fWipe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
|
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
|
||||||
|
@ -413,7 +413,7 @@ std::optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) co
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fs::path& ArgsManager::GetBlocksDirPath()
|
const fs::path& ArgsManager::GetBlocksDirPath() const
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
fs::path& path = m_cached_blocks_path;
|
fs::path& path = m_cached_blocks_path;
|
||||||
@ -429,7 +429,7 @@ const fs::path& ArgsManager::GetBlocksDirPath()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = GetDataDirPath(false);
|
path = GetDataDirBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
path /= BaseParams().DataDir();
|
path /= BaseParams().DataDir();
|
||||||
@ -439,7 +439,7 @@ const fs::path& ArgsManager::GetBlocksDirPath()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fs::path& ArgsManager::GetDataDirPath(bool net_specific) const
|
const fs::path& ArgsManager::GetDataDir(bool net_specific) const
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
fs::path& path = net_specific ? m_cached_network_datadir_path : m_cached_datadir_path;
|
fs::path& path = net_specific ? m_cached_network_datadir_path : m_cached_datadir_path;
|
||||||
@ -473,7 +473,7 @@ const fs::path& ArgsManager::GetDataDirPath(bool net_specific) const
|
|||||||
fs::path ArgsManager::GetBackupsDirPath()
|
fs::path ArgsManager::GetBackupsDirPath()
|
||||||
{
|
{
|
||||||
if (!IsArgSet("-walletbackupsdir"))
|
if (!IsArgSet("-walletbackupsdir"))
|
||||||
return GetDataDirPath() / "backups";
|
return GetDataDirNet() / "backups";
|
||||||
|
|
||||||
return fs::absolute(GetArg("-walletbackupsdir", ""));
|
return fs::absolute(GetArg("-walletbackupsdir", ""));
|
||||||
}
|
}
|
||||||
@ -546,7 +546,7 @@ bool ArgsManager::GetSettingsPath(fs::path* filepath, bool temp) const
|
|||||||
}
|
}
|
||||||
if (filepath) {
|
if (filepath) {
|
||||||
std::string settings = GetArg("-settings", BITCOIN_SETTINGS_FILENAME);
|
std::string settings = GetArg("-settings", BITCOIN_SETTINGS_FILENAME);
|
||||||
*filepath = fsbridge::AbsPathJoin(GetDataDirPath(/* net_specific= */ true), temp ? settings + ".tmp" : settings);
|
*filepath = fsbridge::AbsPathJoin(GetDataDirNet(), temp ? settings + ".tmp" : settings);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -854,11 +854,6 @@ fs::path GetDefaultDataDir()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const fs::path &GetDataDir(bool fNetSpecific)
|
|
||||||
{
|
|
||||||
return gArgs.GetDataDirPath(fNetSpecific);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::path GetBackupsDir()
|
fs::path GetBackupsDir()
|
||||||
{
|
{
|
||||||
return gArgs.GetBackupsDirPath();
|
return gArgs.GetBackupsDirPath();
|
||||||
@ -1479,7 +1474,7 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific)
|
|||||||
if (path.is_absolute()) {
|
if (path.is_absolute()) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
return fsbridge::AbsPathJoin(GetDataDir(net_specific), path);
|
return fsbridge::AbsPathJoin(net_specific ? gArgs.GetDataDirNet() : gArgs.GetDataDirBase(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleBatchPriority()
|
void ScheduleBatchPriority()
|
||||||
|
@ -96,7 +96,6 @@ void ReleaseDirectoryLocks();
|
|||||||
|
|
||||||
bool TryCreateDirectories(const fs::path& p);
|
bool TryCreateDirectories(const fs::path& p);
|
||||||
fs::path GetDefaultDataDir();
|
fs::path GetDefaultDataDir();
|
||||||
const fs::path &GetDataDir(bool fNetSpecific = true);
|
|
||||||
// Return true if -datadir option points to a valid directory or is not specified.
|
// Return true if -datadir option points to a valid directory or is not specified.
|
||||||
bool CheckDataDirOption();
|
bool CheckDataDirOption();
|
||||||
fs::path GetConfigFile(const std::string& confPath);
|
fs::path GetConfigFile(const std::string& confPath);
|
||||||
@ -125,7 +124,7 @@ UniValue RunCommandParseJSON(const std::string& str_command, const std::string&
|
|||||||
* the datadir if they are not absolute.
|
* the datadir if they are not absolute.
|
||||||
*
|
*
|
||||||
* @param path The path to be conditionally prefixed with datadir.
|
* @param path The path to be conditionally prefixed with datadir.
|
||||||
* @param net_specific Forwarded to GetDataDir().
|
* @param net_specific Use network specific datadir variant
|
||||||
* @return The normalized path.
|
* @return The normalized path.
|
||||||
*/
|
*/
|
||||||
fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific = true);
|
fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific = true);
|
||||||
@ -207,7 +206,7 @@ protected:
|
|||||||
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
|
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
|
||||||
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
bool m_accept_any_command GUARDED_BY(cs_args){true};
|
||||||
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
|
||||||
fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
|
||||||
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
|
||||||
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
|
||||||
|
|
||||||
@ -283,16 +282,23 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Blocks path which is network specific
|
* @return Blocks path which is network specific
|
||||||
*/
|
*/
|
||||||
const fs::path& GetBlocksDirPath();
|
const fs::path& GetBlocksDirPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data directory path
|
* Get data directory path
|
||||||
*
|
*
|
||||||
* @param net_specific Append network identifier to the returned path
|
|
||||||
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
|
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
|
||||||
* @post Returned directory path is created unless it is empty
|
* @post Returned directory path is created unless it is empty
|
||||||
*/
|
*/
|
||||||
const fs::path& GetDataDirPath(bool net_specific = true) const;
|
const fs::path& GetDataDirBase() const { return GetDataDir(false); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data directory path with appended network identifier
|
||||||
|
*
|
||||||
|
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
|
||||||
|
* @post Returned directory path is created unless it is empty
|
||||||
|
*/
|
||||||
|
const fs::path& GetDataDirNet() const { return GetDataDir(true); }
|
||||||
|
|
||||||
fs::path GetBackupsDirPath();
|
fs::path GetBackupsDirPath();
|
||||||
|
|
||||||
@ -464,6 +470,15 @@ public:
|
|||||||
void LogArgs() const;
|
void LogArgs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Get data directory path
|
||||||
|
*
|
||||||
|
* @param net_specific Append network identifier to the returned path
|
||||||
|
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
|
||||||
|
* @post Returned directory path is created unless it is empty
|
||||||
|
*/
|
||||||
|
const fs::path& GetDataDir(bool net_specific) const;
|
||||||
|
|
||||||
// Helper function for LogArgs().
|
// Helper function for LogArgs().
|
||||||
void logArgsPrefix(
|
void logArgsPrefix(
|
||||||
const std::string& prefix,
|
const std::string& prefix,
|
||||||
|
@ -1175,7 +1175,7 @@ CoinsViews::CoinsViews(
|
|||||||
size_t cache_size_bytes,
|
size_t cache_size_bytes,
|
||||||
bool in_memory,
|
bool in_memory,
|
||||||
bool should_wipe) : m_dbview(
|
bool should_wipe) : m_dbview(
|
||||||
GetDataDir() / ldb_name, cache_size_bytes, in_memory, should_wipe),
|
gArgs.GetDataDirNet() / ldb_name, cache_size_bytes, in_memory, should_wipe),
|
||||||
m_catcherview(&m_dbview) {}
|
m_catcherview(&m_dbview) {}
|
||||||
|
|
||||||
void CoinsViews::InitCache()
|
void CoinsViews::InitCache()
|
||||||
@ -2415,7 +2415,7 @@ bool CChainState::FlushStateToDisk(
|
|||||||
// twice (once in the log, and once in the tables). This is already
|
// twice (once in the log, and once in the tables). This is already
|
||||||
// an overestimation, as most will delete an existing entry or
|
// an overestimation, as most will delete an existing entry or
|
||||||
// overwrite one. Still, use a conservative safety factor of 2.
|
// overwrite one. Still, use a conservative safety factor of 2.
|
||||||
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
if (!CheckDiskSpace(gArgs.GetDataDirNet(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
||||||
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
|
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
|
||||||
}
|
}
|
||||||
// Flush the chainstate (which may refer to block index entries).
|
// Flush the chainstate (which may refer to block index entries).
|
||||||
@ -4889,7 +4889,7 @@ bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate, FopenFn mocka
|
|||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
int64_t nExpiryTimeout = gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60;
|
int64_t nExpiryTimeout = gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60;
|
||||||
FILE* filestr{mockable_fopen_function(GetDataDir() / "mempool.dat", "rb")};
|
FILE* filestr{mockable_fopen_function(gArgs.GetDataDirNet() / "mempool.dat", "rb")};
|
||||||
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
|
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
|
||||||
if (file.IsNull()) {
|
if (file.IsNull()) {
|
||||||
LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n");
|
LogPrintf("Failed to open mempool file from disk. Continuing anyway.\n");
|
||||||
@ -4994,7 +4994,7 @@ bool DumpMempool(const CTxMemPool& pool, FopenFn mockable_fopen_function, bool s
|
|||||||
int64_t mid = GetTimeMicros();
|
int64_t mid = GetTimeMicros();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FILE* filestr{mockable_fopen_function(GetDataDir() / "mempool.dat.new", "wb")};
|
FILE* filestr{mockable_fopen_function(gArgs.GetDataDirNet() / "mempool.dat.new", "wb")};
|
||||||
if (!filestr) {
|
if (!filestr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -5020,7 +5020,7 @@ bool DumpMempool(const CTxMemPool& pool, FopenFn mockable_fopen_function, bool s
|
|||||||
if (!skip_file_commit && !FileCommit(file.Get()))
|
if (!skip_file_commit && !FileCommit(file.Get()))
|
||||||
throw std::runtime_error("FileCommit failed");
|
throw std::runtime_error("FileCommit failed");
|
||||||
file.fclose();
|
file.fclose();
|
||||||
if (!RenameOver(GetDataDir() / "mempool.dat.new", GetDataDir() / "mempool.dat")) {
|
if (!RenameOver(gArgs.GetDataDirNet() / "mempool.dat.new", gArgs.GetDataDirNet() / "mempool.dat")) {
|
||||||
throw std::runtime_error("Rename failed");
|
throw std::runtime_error("Rename failed");
|
||||||
}
|
}
|
||||||
int64_t last = GetTimeMicros();
|
int64_t last = GetTimeMicros();
|
||||||
|
@ -23,7 +23,7 @@ static std::shared_ptr<BerkeleyEnvironment> GetWalletEnv(const fs::path& path, s
|
|||||||
BOOST_AUTO_TEST_CASE(getwalletenv_file)
|
BOOST_AUTO_TEST_CASE(getwalletenv_file)
|
||||||
{
|
{
|
||||||
std::string test_name = "test_name.dat";
|
std::string test_name = "test_name.dat";
|
||||||
const fs::path datadir = GetDataDir();
|
const fs::path datadir = gArgs.GetDataDirNet();
|
||||||
fs::path file_path = datadir / test_name;
|
fs::path file_path = datadir / test_name;
|
||||||
#if BOOST_VERSION >= 107700
|
#if BOOST_VERSION >= 107700
|
||||||
std::ofstream f(BOOST_FILESYSTEM_C_STR(file_path));
|
std::ofstream f(BOOST_FILESYSTEM_C_STR(file_path));
|
||||||
@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(getwalletenv_file)
|
|||||||
BOOST_AUTO_TEST_CASE(getwalletenv_directory)
|
BOOST_AUTO_TEST_CASE(getwalletenv_directory)
|
||||||
{
|
{
|
||||||
std::string expected_name = "wallet.dat";
|
std::string expected_name = "wallet.dat";
|
||||||
const fs::path datadir = GetDataDir();
|
const fs::path datadir = gArgs.GetDataDirNet();
|
||||||
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::shared_ptr<BerkeleyEnvironment> env = GetWalletEnv(datadir, filename);
|
std::shared_ptr<BerkeleyEnvironment> env = GetWalletEnv(datadir, filename);
|
||||||
@ -51,8 +51,8 @@ BOOST_AUTO_TEST_CASE(getwalletenv_directory)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_multiple)
|
BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_multiple)
|
||||||
{
|
{
|
||||||
fs::path datadir = GetDataDir() / "1";
|
fs::path datadir = gArgs.GetDataDirNet() / "1";
|
||||||
fs::path datadir_2 = GetDataDir() / "2";
|
fs::path datadir_2 = gArgs.GetDataDirNet() / "2";
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
std::shared_ptr<BerkeleyEnvironment> env_1 = GetWalletEnv(datadir, filename);
|
std::shared_ptr<BerkeleyEnvironment> env_1 = GetWalletEnv(datadir, filename);
|
||||||
@ -65,8 +65,8 @@ BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_multiple)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_free_instance)
|
BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_free_instance)
|
||||||
{
|
{
|
||||||
fs::path datadir = GetDataDir() / "1";
|
fs::path datadir = gArgs.GetDataDirNet() / "1";
|
||||||
fs::path datadir_2 = GetDataDir() / "2";
|
fs::path datadir_2 = gArgs.GetDataDirNet() / "2";
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
std::shared_ptr <BerkeleyEnvironment> env_1_a = GetWalletEnv(datadir, filename);
|
std::shared_ptr <BerkeleyEnvironment> env_1_a = GetWalletEnv(datadir, filename);
|
||||||
|
@ -16,7 +16,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainNam
|
|||||||
std::string sep;
|
std::string sep;
|
||||||
sep += fs::path::preferred_separator;
|
sep += fs::path::preferred_separator;
|
||||||
|
|
||||||
m_datadir = GetDataDir();
|
m_datadir = gArgs.GetDataDirNet();
|
||||||
m_cwd = fs::current_path();
|
m_cwd = fs::current_path();
|
||||||
|
|
||||||
m_walletdir_path_cases["default"] = m_datadir / "wallets";
|
m_walletdir_path_cases["default"] = m_datadir / "wallets";
|
||||||
|
@ -272,7 +272,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
|||||||
SetMockTime(KEY_TIME);
|
SetMockTime(KEY_TIME);
|
||||||
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
|
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
|
||||||
|
|
||||||
std::string backup_file = (GetDataDir() / "wallet.backup").string();
|
std::string backup_file = (gArgs.GetDataDirNet() / "wallet.backup").string();
|
||||||
|
|
||||||
// Import key into wallet and call dumpwallet to create backup file.
|
// Import key into wallet and call dumpwallet to create backup file.
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ fs::path GetWalletDir()
|
|||||||
path = "";
|
path = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = GetDataDir();
|
path = gArgs.GetDataDirNet();
|
||||||
// If a wallets directory exists, use that, otherwise default to GetDataDir
|
// If a wallets directory exists, use that, otherwise default to GetDataDir
|
||||||
if (fs::is_directory(path / "wallets")) {
|
if (fs::is_directory(path / "wallets")) {
|
||||||
path /= "wallets";
|
path /= "wallets";
|
||||||
|
Loading…
Reference in New Issue
Block a user