aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-03-07 10:00:38 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-03-07 10:00:53 +0100
commit6687bb24ae88c9f48070dbeafc5f00ce7a56d4d8 (patch)
treec4c45863769c7ec8860bdfad6e500d05dae11f99 /src/init.cpp
parent384866e870b6f50dab6951f1e81e5fda92679510 (diff)
parent60aa179d8f9a675efa2d78eaadc09e3ba450f50f (diff)
downloadbitcoin-6687bb24ae88c9f48070dbeafc5f00ce7a56d4d8.tar.xz
Merge bitcoin/bitcoin#24306: util: Make ArgsManager::GetPathArg more widely usable
60aa179d8f9a675efa2d78eaadc09e3ba450f50f Use GetPathArg where possible (Pavol Rusnak) 5b946edd73640c6ecdfb4cbac1d4351e634678dc util, refactor: Use GetPathArg to read "-settings" value (Ryan Ofsky) 687e655ae2970f2f13aca0267c7de86dc69be763 util: Add GetPathArg default path argument (Ryan Ofsky) Pull request description: Improve `ArgsManager::GetPathArg` method added in recent PR #24265, so it is usable more places. This PR starts to use it for the `-settings` option. This can also be helpful for #24274 which is parsing more path options. - Add `GetPathArg` default argument so it is less awkward to use to parse options that have default values. - Fix `GetPathArg` negated argument handling. Return path{} not path{"0"} when path argument is negated. - Add unit tests for default and negated cases - Move `GetPathArg` method declaration next to `GetArg` declaration. The two methods are close substitutes for each, so this should help keep them consistent and make them more discoverable. ACKs for top commit: w0xlt: Tested ACK 60aa179 on Ubuntu 21.10 hebasto: re-ACK 60aa179d8f9a675efa2d78eaadc09e3ba450f50f Tree-SHA512: 3d24b885d8bbeef39ea5d0556e2f09b9e5f4a21179cef11cbbbc1b84da29c8fb66ba698889054ce28d80bc25926687654c8532ed46054bf5b2dd1837866bd1cd
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp
index a3d53c3fae..3110797194 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -135,7 +135,7 @@ static const char* BITCOIN_PID_FILENAME = "bitcoind.pid";
static fs::path GetPidFile(const ArgsManager& args)
{
- return AbsPathForConfigVal(fs::PathFromString(args.GetArg("-pid", BITCOIN_PID_FILENAME)));
+ return AbsPathForConfigVal(args.GetPathArg("-pid", BITCOIN_PID_FILENAME));
}
[[nodiscard]] static bool CreatePidFile(const ArgsManager& args)
@@ -1229,10 +1229,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Read asmap file if configured
std::vector<bool> asmap;
if (args.IsArgSet("-asmap")) {
- fs::path asmap_path = fs::PathFromString(args.GetArg("-asmap", ""));
- if (asmap_path.empty()) {
- asmap_path = fs::PathFromString(DEFAULT_ASMAP_FILENAME);
- }
+ fs::path asmap_path = args.GetPathArg("-asmap", DEFAULT_ASMAP_FILENAME);
if (!asmap_path.is_absolute()) {
asmap_path = gArgs.GetDataDirNet() / asmap_path;
}