Bitcoin Core  23.99.0
P2P Digital Currency
system.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
10 #ifndef BITCOIN_UTIL_SYSTEM_H
11 #define BITCOIN_UTIL_SYSTEM_H
12 
13 #if defined(HAVE_CONFIG_H)
14 #include <config/bitcoin-config.h>
15 #endif
16 
17 #include <compat/compat.h>
18 #include <compat/assumptions.h>
19 #include <fs.h>
20 #include <logging.h>
21 #include <sync.h>
22 #include <tinyformat.h>
23 #include <util/settings.h>
24 #include <util/time.h>
25 
26 #include <any>
27 #include <exception>
28 #include <map>
29 #include <optional>
30 #include <set>
31 #include <stdint.h>
32 #include <string>
33 #include <utility>
34 #include <vector>
35 
36 class UniValue;
37 
38 // Application startup time (used for uptime calculation)
39 int64_t GetStartupTime();
40 
41 extern const char * const BITCOIN_CONF_FILENAME;
42 extern const char * const BITCOIN_SETTINGS_FILENAME;
43 
44 void SetupEnvironment();
45 bool SetupNetworking();
46 
47 template<typename... Args>
48 bool error(const char* fmt, const Args&... args)
49 {
50  LogPrintf("ERROR: %s\n", tfm::format(fmt, args...));
51  return false;
52 }
53 
54 void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
55 
60 bool FileCommit(FILE *file);
61 
66 void DirectoryCommit(const fs::path &dirname);
67 
68 bool TruncateFile(FILE *file, unsigned int length);
69 int RaiseFileDescriptorLimit(int nMinFD);
70 void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
71 
76 [[nodiscard]] bool RenameOver(fs::path src, fs::path dest);
77 
78 bool LockDirectory(const fs::path& directory, const fs::path& lockfile_name, bool probe_only=false);
79 void UnlockDirectory(const fs::path& directory, const fs::path& lockfile_name);
80 bool DirIsWritable(const fs::path& directory);
81 bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
82 
89 std::streampos GetFileSize(const char* path, std::streamsize max = std::numeric_limits<std::streamsize>::max());
90 
95 
96 bool TryCreateDirectories(const fs::path& p);
98 // Return true if -datadir option points to a valid directory or is not specified.
99 bool CheckDataDirOption();
100 fs::path GetConfigFile(const fs::path& configuration_file_path);
101 #ifdef WIN32
102 fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
103 #endif
104 #ifndef WIN32
105 std::string ShellEscape(const std::string& arg);
106 #endif
107 #if HAVE_SYSTEM
108 void runCommand(const std::string& strCommand);
109 #endif
110 
117 UniValue RunCommandParseJSON(const std::string& str_command, const std::string& str_std_in="");
118 
127 fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific = true);
128 
129 inline bool IsSwitchChar(char c)
130 {
131 #ifdef WIN32
132  return c == '-' || c == '/';
133 #else
134  return c == '-';
135 #endif
136 }
137 
138 enum class OptionsCategory {
139  OPTIONS,
140  CONNECTION,
141  WALLET,
143  ZMQ,
144  DEBUG_TEST,
145  CHAINPARAMS,
146  NODE_RELAY,
148  RPC,
149  GUI,
150  COMMANDS,
152 
153  HIDDEN // Always the last option to avoid printing these in the help
154 };
155 
157 {
158  std::string m_name;
159  std::string m_file;
160  int m_line;
161 };
162 
163 std::string SettingToString(const util::SettingsValue&, const std::string&);
164 std::optional<std::string> SettingToString(const util::SettingsValue&);
165 
166 int64_t SettingToInt(const util::SettingsValue&, int64_t);
167 std::optional<int64_t> SettingToInt(const util::SettingsValue&);
168 
169 bool SettingToBool(const util::SettingsValue&, bool);
170 std::optional<bool> SettingToBool(const util::SettingsValue&);
171 
173 {
174 public:
179  enum Flags : uint32_t {
180  ALLOW_ANY = 0x01,
181  // ALLOW_BOOL = 0x02, //!< unimplemented, draft implementation in #16545
182  // ALLOW_INT = 0x04, //!< unimplemented, draft implementation in #16545
183  // ALLOW_STRING = 0x08, //!< unimplemented, draft implementation in #16545
184  // ALLOW_LIST = 0x10, //!< unimplemented, draft implementation in #16545
187 
188  DEBUG_ONLY = 0x100,
189  /* Some options would cause cross-contamination if values for
190  * mainnet were used while running on regtest/testnet (or vice-versa).
191  * Setting them as NETWORK_ONLY ensures that sharing a config file
192  * between mainnet and regtest/testnet won't cause problems due to these
193  * parameters by accident. */
194  NETWORK_ONLY = 0x200,
195  // This argument's value is sensitive (such as a password).
196  SENSITIVE = 0x400,
197  COMMAND = 0x800,
198  };
199 
200 protected:
201  struct Arg
202  {
203  std::string m_help_param;
204  std::string m_help_text;
205  unsigned int m_flags;
206  };
207 
209  util::Settings m_settings GUARDED_BY(cs_args);
210  std::vector<std::string> m_command GUARDED_BY(cs_args);
211  std::string m_network GUARDED_BY(cs_args);
212  std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
213  std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
214  bool m_accept_any_command GUARDED_BY(cs_args){true};
215  std::list<SectionInfo> m_config_sections GUARDED_BY(cs_args);
216  mutable fs::path m_cached_blocks_path GUARDED_BY(cs_args);
217  mutable fs::path m_cached_datadir_path GUARDED_BY(cs_args);
218  mutable fs::path m_cached_network_datadir_path GUARDED_BY(cs_args);
219 
220  [[nodiscard]] bool ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys = false);
221 
227  bool UseDefaultSection(const std::string& arg) const EXCLUSIVE_LOCKS_REQUIRED(cs_args);
228 
229  public:
237  util::SettingsValue GetSetting(const std::string& arg) const;
238 
242  std::vector<util::SettingsValue> GetSettingsList(const std::string& arg) const;
243 
244  ArgsManager();
245  ~ArgsManager();
246 
250  void SelectConfigNetwork(const std::string& network);
251 
252  [[nodiscard]] bool ParseParameters(int argc, const char* const argv[], std::string& error);
253  [[nodiscard]] bool ReadConfigFiles(std::string& error, bool ignore_invalid_keys = false);
254 
261  const std::set<std::string> GetUnsuitableSectionOnlyArgs() const;
262 
266  const std::list<SectionInfo> GetUnrecognizedSections() const;
267 
268  struct Command {
270  std::string command;
275  std::vector<std::string> args;
276  };
280  std::optional<const Command> GetCommand() const;
281 
287  const fs::path& GetBlocksDirPath() const;
288 
295  const fs::path& GetDataDirBase() const { return GetDataDir(false); }
296 
303  const fs::path& GetDataDirNet() const { return GetDataDir(true); }
304 
308  void ClearPathCache();
309 
316  std::vector<std::string> GetArgs(const std::string& strArg) const;
317 
324  bool IsArgSet(const std::string& strArg) const;
325 
333  bool IsArgNegated(const std::string& strArg) const;
334 
342  std::string GetArg(const std::string& strArg, const std::string& strDefault) const;
343  std::optional<std::string> GetArg(const std::string& strArg) const;
344 
355  fs::path GetPathArg(std::string arg, const fs::path& default_value = {}) const;
356 
364  int64_t GetIntArg(const std::string& strArg, int64_t nDefault) const;
365  std::optional<int64_t> GetIntArg(const std::string& strArg) const;
366 
374  bool GetBoolArg(const std::string& strArg, bool fDefault) const;
375  std::optional<bool> GetBoolArg(const std::string& strArg) const;
376 
384  bool SoftSetArg(const std::string& strArg, const std::string& strValue);
385 
393  bool SoftSetBoolArg(const std::string& strArg, bool fValue);
394 
395  // Forces an arg setting. Called by SoftSetArg() if the arg hasn't already
396  // been set. Also called directly in testing.
397  void ForceSetArg(const std::string& strArg, const std::string& strValue);
398 
403  std::string GetChainName() const;
404 
408  void AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat);
409 
413  void AddCommand(const std::string& cmd, const std::string& help);
414 
418  void AddHiddenArgs(const std::vector<std::string>& args);
419 
423  void ClearArgs() {
424  LOCK(cs_args);
425  m_available_args.clear();
426  m_network_only_args.clear();
427  }
428 
432  std::string GetHelpMessage() const;
433 
438  std::optional<unsigned int> GetArgFlags(const std::string& name) const;
439 
445  bool InitSettings(std::string& error);
446 
451  bool GetSettingsPath(fs::path* filepath = nullptr, bool temp = false, bool backup = false) const;
452 
456  bool ReadSettingsFile(std::vector<std::string>* errors = nullptr);
457 
462  bool WriteSettingsFile(std::vector<std::string>* errors = nullptr, bool backup = false) const;
463 
468  util::SettingsValue GetPersistentSetting(const std::string& name) const;
469 
473  template <typename Fn>
474  void LockSettings(Fn&& fn)
475  {
476  LOCK(cs_args);
477  fn(m_settings);
478  }
479 
484  void LogArgs() const;
485 
486 private:
494  const fs::path& GetDataDir(bool net_specific) const;
495 
496  // Helper function for LogArgs().
497  void logArgsPrefix(
498  const std::string& prefix,
499  const std::string& section,
500  const std::map<std::string, std::vector<util::SettingsValue>>& args) const;
501 };
502 
503 extern ArgsManager gArgs;
504 
508 bool HelpRequested(const ArgsManager& args);
509 
512 
519 std::string HelpMessageGroup(const std::string& message);
520 
528 std::string HelpMessageOpt(const std::string& option, const std::string& message);
529 
534 int GetNumCores();
535 
541 void ScheduleBatchPriority();
542 
543 namespace util {
544 
546 template <typename Tdst, typename Tsrc>
547 inline void insert(Tdst& dst, const Tsrc& src) {
548  dst.insert(dst.begin(), src.begin(), src.end());
549 }
550 template <typename TsetT, typename Tsrc>
551 inline void insert(std::set<TsetT>& dst, const Tsrc& src) {
552  dst.insert(src.begin(), src.end());
553 }
554 
560 template<typename T>
561 T* AnyPtr(const std::any& any) noexcept
562 {
563  T* const* ptr = std::any_cast<T*>(&any);
564  return ptr ? *ptr : nullptr;
565 }
566 
567 #ifdef WIN32
568 class WinCmdLineArgs
569 {
570 public:
571  WinCmdLineArgs();
572  ~WinCmdLineArgs();
573  std::pair<int, char**> get();
574 
575 private:
576  int argc;
577  char** argv;
578  std::vector<std::string> args;
579 };
580 #endif
581 
582 } // namespace util
583 
584 #endif // BITCOIN_UTIL_SYSTEM_H
ArgsManager::GetPathArg
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Definition: system.cpp:393
RenameOver
bool RenameOver(fs::path src, fs::path dest)
Rename src to dest.
Definition: system.cpp:1136
ArgsManager::LogArgs
void LogArgs() const
Log the config file options and the command line arguments, useful for troubleshooting.
Definition: system.cpp:1124
SetupEnvironment
void SetupEnvironment()
Definition: system.cpp:1374
ArgsManager::GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:654
DirectoryCommit
void DirectoryCommit(const fs::path &dirname)
Sync directory contents.
Definition: system.cpp:1204
ArgsManager::AddHiddenArgs
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
Definition: system.cpp:732
ArgsManager::ClearPathCache
void ClearPathCache()
Clear cached directory paths.
Definition: system.cpp:462
HelpRequested
bool HelpRequested(const ArgsManager &args)
Definition: system.cpp:808
tinyformat::format
void format(std::ostream &out, const char *fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1062
ArgsManager::GetArgFlags
std::optional< unsigned int > GetArgFlags(const std::string &name) const
Return Flags for known arg.
Definition: system.cpp:381
util::Settings
Stored settings.
Definition: settings.h:31
fs.h
ArgsManager::Command::args
std::vector< std::string > args
If command is non-empty: Any args that followed it If command is empty: The unregistered command and ...
Definition: system.h:275
OptionsCategory::RPC
@ RPC
GetFileSize
std::streampos GetFileSize(const char *path, std::streamsize max=std::numeric_limits< std::streamsize >::max())
Get the size of a file by scanning it.
Definition: system.cpp:154
flags
int flags
Definition: bitcoin-tx.cpp:526
ArgsManager::GetSetting
util::SettingsValue GetSetting(const std::string &arg) const
Get setting value.
Definition: system.cpp:1093
ArgsManager::GetDataDirNet
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: system.h:303
ArgsManager::UseDefaultSection
bool UseDefaultSection(const std::string &arg) const EXCLUSIVE_LOCKS_REQUIRED(cs_args)
Returns true if settings values from the default section should be used, depending on the current net...
Definition: system.cpp:1088
ArgsManager::SoftSetBoolArg
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: system.cpp:685
help
static RPCHelpMan help()
Definition: server.cpp:136
ArgsManager::GetBlocksDirPath
const fs::path & GetBlocksDirPath() const
Get blocks directory path.
Definition: system.cpp:403
BITCOIN_SETTINGS_FILENAME
const char *const BITCOIN_SETTINGS_FILENAME
Definition: system.cpp:84
sync.h
ArgsManager::GetHelpMessage
std::string GetHelpMessage() const
Get the help string.
Definition: system.cpp:739
gArgs
ArgsManager gArgs
Definition: system.cpp:86
ArgsManager::GUARDED_BY
bool m_accept_any_command GUARDED_BY(cs_args)
Definition: system.h:214
ArgsManager::ALLOW_ANY
@ ALLOW_ANY
disable validation
Definition: system.h:180
ArgsManager::DISALLOW_NEGATION
@ DISALLOW_NEGATION
disallow -nofoo syntax
Definition: system.h:185
ArgsManager::GetChainName
std::string GetChainName() const
Returns the appropriate chain name from the program arguments.
Definition: system.cpp:1058
ArgsManager::IsArgSet
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:500
HelpMessageGroup
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
Definition: system.cpp:823
ArgsManager::GetPersistentSetting
util::SettingsValue GetPersistentSetting(const std::string &name) const
Get current setting from config file or read/write settings file, ignoring nonpersistent command line...
Definition: system.cpp:592
AllocateFileRange
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length)
this function tries to make a particular range of a file allocated (corresponding to disk space) it i...
Definition: system.cpp:1250
AnnotatedMixin< std::recursive_mutex >
ArgsManager::InitSettings
bool InitSettings(std::string &error)
Read and update settings file with saved settings.
Definition: system.cpp:505
OptionsCategory::CONNECTION
@ CONNECTION
SectionInfo::m_file
std::string m_file
Definition: system.h:159
bitcoin-config.h
ArgsManager::DISALLOW_ELISION
@ DISALLOW_ELISION
disallow -foo syntax that doesn't assign any value
Definition: system.h:186
cmd
const auto cmd
Definition: bitcoin-util.cpp:164
TryCreateDirectories
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by create_directories if the requested directory exists.
Definition: system.cpp:1159
ArgsManager::DEBUG_ONLY
@ DEBUG_ONLY
Definition: system.h:188
CheckDataDirOption
bool CheckDataDirOption()
Definition: system.cpp:882
UniValue
Definition: univalue.h:18
FileCommit
bool FileCommit(FILE *file)
Ensure file contents are fully committed to disk, using a platform-specific feature analogous to fsyn...
Definition: system.cpp:1173
tinyformat.h
ArgsManager::~ArgsManager
~ArgsManager()
ArgsManager::Arg
Definition: system.h:201
prefix
const char * prefix
Definition: rest.cpp:926
ArgsManager::GetDataDirBase
const fs::path & GetDataDirBase() const
Get data directory path.
Definition: system.h:295
ArgsManager::Arg::m_flags
unsigned int m_flags
Definition: system.h:205
GetDefaultDataDir
fs::path GetDefaultDataDir()
Definition: system.cpp:857
ArgsManager::cs_args
RecursiveMutex cs_args
Definition: system.h:208
AbsPathForConfigVal
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific=true)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
Definition: system.cpp:1424
settings.h
CheckDiskSpace
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes=0)
Definition: system.cpp:146
OptionsCategory::HIDDEN
@ HIDDEN
OptionsCategory::NODE_RELAY
@ NODE_RELAY
RaiseFileDescriptorLimit
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
Definition: system.cpp:1227
fs::path
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
ArgsManager::SoftSetArg
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
Definition: system.cpp:677
compat.h
ArgsManager::AddArg
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:711
UnlockDirectory
void UnlockDirectory(const fs::path &directory, const fs::path &lockfile_name)
Definition: system.cpp:121
HelpMessageOpt
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
Definition: system.cpp:827
IsSwitchChar
bool IsSwitchChar(char c)
Definition: system.h:129
time.h
DirIsWritable
bool DirIsWritable(const fs::path &directory)
Definition: system.cpp:133
ArgsManager::GetUnsuitableSectionOnlyArgs
const std::set< std::string > GetUnsuitableSectionOnlyArgs() const
Log warnings for options in m_section_only_args when they are specified in the default section but no...
Definition: system.cpp:258
ArgsManager::ForceSetArg
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: system.cpp:693
ArgsManager::GetArg
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:604
LogPrintf
#define LogPrintf(...)
Definition: logging.h:205
OptionsCategory::OPTIONS
@ OPTIONS
ArgsManager::Command::command
std::string command
The command (if one has been registered with AddCommand), or empty.
Definition: system.h:270
ArgsManager::ArgsManager
ArgsManager()
ArgsManager::Arg::m_help_param
std::string m_help_param
Definition: system.h:203
ArgsManager::ParseParameters
bool ParseParameters(int argc, const char *const argv[], std::string &error)
Definition: system.cpp:300
ArgsManager::WriteSettingsFile
bool WriteSettingsFile(std::vector< std::string > *errors=nullptr, bool backup=false) const
Write settings file or backup settings file.
Definition: system.cpp:572
ArgsManager::GUARDED_BY
util::Settings m_settings GUARDED_BY(cs_args)
ArgsManager::ReadConfigFiles
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
Definition: system.cpp:966
ScheduleBatchPriority
void ScheduleBatchPriority()
On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive...
Definition: system.cpp:1432
ArgsManager::ReadConfigStream
bool ReadConfigStream(std::istream &stream, const std::string &filepath, std::string &error, bool ignore_invalid_keys=false)
Definition: system.cpp:938
ArgsManager::SENSITIVE
@ SENSITIVE
Definition: system.h:196
ArgsManager::Flags
Flags
Flags controlling how config and command line arguments are validated and interpreted.
Definition: system.h:179
SectionInfo::m_name
std::string m_name
Definition: system.h:158
OptionsCategory
OptionsCategory
Definition: system.h:138
assumptions.h
OptionsCategory::ZMQ
@ ZMQ
SetupHelpOptions
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
Definition: system.cpp:813
name
const char * name
Definition: rest.cpp:46
OptionsCategory::BLOCK_CREATION
@ BLOCK_CREATION
ArgsManager::ReadSettingsFile
bool ReadSettingsFile(std::vector< std::string > *errors=nullptr)
Read settings file.
Definition: system.cpp:549
ArgsManager::SelectConfigNetwork
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:294
ArgsManager::LockSettings
void LockSettings(Fn &&fn)
Access settings with lock held.
Definition: system.h:474
ArgsManager::GetSettingsList
std::vector< util::SettingsValue > GetSettingsList(const std::string &arg) const
Get list of setting values.
Definition: system.cpp:1101
ArgsManager::IsArgNegated
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
Definition: system.cpp:599
SectionInfo
Definition: system.h:156
ArgsManager::COMMAND
@ COMMAND
Definition: system.h:197
ArgsManager
Definition: system.h:172
ArgsManager::Command
Definition: system.h:268
OptionsCategory::WALLET_DEBUG_TEST
@ WALLET_DEBUG_TEST
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
LOCK
#define LOCK(cs)
Definition: sync.h:261
GetStartupTime
int64_t GetStartupTime()
Definition: system.cpp:1419
ArgsManager::logArgsPrefix
void logArgsPrefix(const std::string &prefix, const std::string &section, const std::map< std::string, std::vector< util::SettingsValue >> &args) const
Definition: system.cpp:1107
OptionsCategory::WALLET
@ WALLET
util::insert
void insert(Tdst &dst, const Tsrc &src)
Simplification of std insertion.
Definition: system.h:547
ArgsManager::GetUnrecognizedSections
const std::list< SectionInfo > GetUnrecognizedSections() const
Log warnings for unrecognized section names in the config file.
Definition: system.cpp:278
SetupNetworking
bool SetupNetworking()
Definition: system.cpp:1401
ArgsManager::ClearArgs
void ClearArgs()
Clear available arguments.
Definition: system.h:423
SectionInfo::m_line
int m_line
Definition: system.h:160
OptionsCategory::DEBUG_TEST
@ DEBUG_TEST
ArgsManager::GetCommand
std::optional< const Command > GetCommand() const
Get the command and command args (returns std::nullopt if no command provided)
Definition: system.cpp:471
SettingToBool
bool SettingToBool(const util::SettingsValue &, bool)
Definition: system.cpp:672
SettingToInt
int64_t SettingToInt(const util::SettingsValue &, int64_t)
Definition: system.cpp:649
ArgsManager::GetSettingsPath
bool GetSettingsPath(fs::path *filepath=nullptr, bool temp=false, bool backup=false) const
Get settings file path, or return false if read-write settings were disabled with -nosettings.
Definition: system.cpp:523
m_command
CRPCCommand m_command
Definition: interfaces.cpp:497
OptionsCategory::COMMANDS
@ COMMANDS
util::AnyPtr
T * AnyPtr(const std::any &any) noexcept
Helper function to access the contained object of a std::any instance.
Definition: system.h:561
ArgsManager::Arg::m_help_text
std::string m_help_text
Definition: system.h:204
OptionsCategory::REGISTER_COMMANDS
@ REGISTER_COMMANDS
ArgsManager::GetArgs
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: system.cpp:491
ReleaseDirectoryLocks
void ReleaseDirectoryLocks()
Release all directory locks.
Definition: system.cpp:127
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:48
OptionsCategory::CHAINPARAMS
@ CHAINPARAMS
BITCOIN_CONF_FILENAME
const char *const BITCOIN_CONF_FILENAME
Definition: system.cpp:83
OptionsCategory::GUI
@ GUI
T
#define T(expected, seed, data)
GetConfigFile
fs::path GetConfigFile(const fs::path &configuration_file_path)
Definition: system.cpp:888
RunCommandParseJSON
UniValue RunCommandParseJSON(const std::string &str_command, const std::string &str_std_in="")
Execute a command which returns JSON, and parse the result.
Definition: system.cpp:1335
ArgsManager::GetIntArg
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
Definition: system.cpp:629
TruncateFile
bool TruncateFile(FILE *file, unsigned int length)
Definition: system.cpp:1215
util
Definition: overloaded.h:8
ArgsManager::AddCommand
void AddCommand(const std::string &cmd, const std::string &help)
Add subcommand.
Definition: system.cpp:699
LockDirectory
bool LockDirectory(const fs::path &directory, const fs::path &lockfile_name, bool probe_only=false)
Definition: system.cpp:97
ShellEscape
std::string ShellEscape(const std::string &arg)
Definition: system.cpp:1313
GetNumCores
int GetNumCores()
Return the number of cores available on the current system.
Definition: system.cpp:1413
ArgsManager::NETWORK_ONLY
@ NETWORK_ONLY
Definition: system.h:194
ArgsManager::GetDataDir
const fs::path & GetDataDir(bool net_specific) const
Get data directory path.
Definition: system.cpp:428
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
Definition: system.cpp:850
args
ArgsManager args
Definition: notifications.cpp:36
SettingToString
std::string SettingToString(const util::SettingsValue &, const std::string &)
Definition: system.cpp:624