Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
| Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | void ArgsManager::ForceSetMultiArg(const std::string &strArg, | ||||
| mapMultiArgs[strArg].push_back(strValue); | mapMultiArgs[strArg].push_back(strValue); | ||||
| } | } | ||||
| void ArgsManager::ClearArg(const std::string &strArg) { | void ArgsManager::ClearArg(const std::string &strArg) { | ||||
| LOCK(cs_args); | LOCK(cs_args); | ||||
| mapArgs.erase(strArg); | mapArgs.erase(strArg); | ||||
| } | } | ||||
| bool ArgsManager::IsHelpSet() { | |||||
| return IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || | |||||
| IsArgSet("-version"); | |||||
| } | |||||
| bool ArgsManager::IsVersionSet() { | |||||
| return IsArgSet("-version"); | |||||
| } | |||||
| bool ArgsManager::IsDataDirSet() { | |||||
| return IsArgSet("-datadir"); | |||||
| } | |||||
| std::string ArgsManager::GetDataDir() { | |||||
| return GetArg("-datadir", ""); | |||||
| } | |||||
| std::string ArgsManager::DataDirHelp() { | |||||
| return HelpMessageOpt("-datadir=<dir>", _("Specify data directory")); | |||||
| }; | |||||
| bool ArgsManager::SoftSetDataDir(const std::string &strValue) { | |||||
| return SoftSetArg("-datadir", strValue); | |||||
| }; | |||||
| bool ArgsManager::IsStopAfterBlockImportSet() { | |||||
| return GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT); | |||||
| }; | |||||
| std::string ArgsManager::StopAfterBlockImportHelp() { | |||||
| return HelpMessageOpt( | |||||
| "-stopafterblockimport", | |||||
| strprintf("Stop running after importing blocks from disk (default: %d)", | |||||
| DEFAULT_STOPAFTERBLOCKIMPORT)); | |||||
| }; | |||||
| bool ArgsManager::IsPersistMempoolSet() { | |||||
| return GetBoolArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL); | |||||
| }; | |||||
| std::string ArgsManager::PersistMempoolHelp() { | |||||
| return HelpMessageOpt("-persistmempool", | |||||
| strprintf(_("Whether to save the mempool on shutdown " | |||||
| "and load on restart (default: %u)"), | |||||
| DEFAULT_PERSIST_MEMPOOL)); | |||||
| }; | |||||
| bool ArgsManager::SoftSetPersistMempool(bool fValue) { | |||||
| return SoftSetBoolArg("-persistmempool", false); | |||||
| }; | |||||
| static const int screenWidth = 79; | static const int screenWidth = 79; | ||||
| static const int optIndent = 2; | static const int optIndent = 2; | ||||
| static const int msgIndent = 7; | static const int msgIndent = 7; | ||||
| std::string HelpMessageGroup(const std::string &message) { | std::string HelpMessageGroup(const std::string &message) { | ||||
| return std::string(message) + std::string("\n\n"); | return std::string(message) + std::string("\n\n"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | const fs::path &GetDataDir(bool fNetSpecific) { | ||||
| LOCK(csPathCached); | LOCK(csPathCached); | ||||
| fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached; | fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached; | ||||
| // This can be called during exceptions by LogPrintf(), so we cache the | // This can be called during exceptions by LogPrintf(), so we cache the | ||||
| // value so we don't have to do memory allocations after that. | // value so we don't have to do memory allocations after that. | ||||
| if (!path.empty()) return path; | if (!path.empty()) return path; | ||||
| if (gArgs.IsArgSet("-datadir")) { | if (gArgs.IsDataDirSet()) { | ||||
| path = fs::system_complete(gArgs.GetArg("-datadir", "")); | path = fs::system_complete(gArgs.GetDataDir()); | ||||
| if (!fs::is_directory(path)) { | if (!fs::is_directory(path)) { | ||||
| path = ""; | path = ""; | ||||
| return path; | return path; | ||||
| } | } | ||||
| } else { | } else { | ||||
| path = GetDefaultDataDir(); | path = GetDefaultDataDir(); | ||||
| } | } | ||||
| if (fNetSpecific) path /= BaseParams().DataDir(); | if (fNetSpecific) path /= BaseParams().DataDir(); | ||||
| ▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines | |||||