Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
util.cpp
Go to the documentation of this file.
144 // We don't use them so we don't require the config. However some of our libs may call functions
145 // which attempt to load the config file, possibly resulting in an exit() or crash if it is missing
146 // or corrupt. Explicitly tell OpenSSL not to try to load the file. The result for our libs will be
363 if (LogCategories[i].flag != BCLog::NONE && LogCategories[i].flag != BCLog::ALL && LogAcceptCategory(LogCategories[i].flag)) {
556 static inline void AddArgs(std::vector<std::string>& res, const MapArgs& map_args, const std::string& arg)
567 static inline std::pair<bool,std::string> GetArgHelper(const MapArgs& map_args, const std::string& arg, bool getLast = false)
622 static inline bool GetNetBoolArg(const ArgsManager &am, const std::string& net_arg, bool interpret_bool)
713 found_result = ArgsManagerHelper::GetArgHelper(m_config_args, ArgsManagerHelper::NetworkArg(*this, arg));
721 LogPrintf("Warning: Config setting for %s only applied on %s network when in [%s] section.\n", arg, m_network, m_network);
774 ArgsManagerHelper::AddArgs(result, m_config_args, ArgsManagerHelper::NetworkArg(*this, strArg));
893 std::string message = strprintf("\"%s\" raised an exception\n%s", pszExceptionOrigin, GetPrettyExceptionStr(pex));
988 for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it)
1022 throw std::runtime_error(strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", "").c_str()));
1295 // `doneCnt` should be at least `futures.size()` if tp size was increased (for whatever reason),
1364 std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYear, unsigned int nEndYear)
1366 std::string strCopyrightHolders = strPrefix + strprintf(" %u-%u ", nStartYear, nEndYear) + strprintf(_(COPYRIGHT_HOLDERS), _(COPYRIGHT_HOLDERS_SUBSTITUTION));
1368 // Check for untranslated substitution to make sure Dash Core copyright is not removed by accident
1369 if (strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION).find("Dash Core") == std::string::npos) {
1370 strCopyrightHolders += "\n" + strPrefix + strprintf(" %u-%u ", 2014, nEndYear) + "The Dash Core developers";
1372 // Check for untranslated substitution to make sure Bitcoin Core copyright is not removed by accident
1373 if (strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION).find("Bitcoin Core") == std::string::npos) {
1374 strCopyrightHolders += "\n" + strPrefix + strprintf(" %u-%u ", 2009, nEndYear) + "The Bitcoin Core developers";
Definition: util.h:124
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
Definition: util.cpp:884
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: util.cpp:784
Definition: util.h:138
Definition: util.h:114
FILE * freopen(const fs::path &p, const char *mode, FILE *stream)
Definition: fs.cpp:10
Definition: util.h:110
std::string ListActiveLogCategoriesString()
Returns a string with the list of active log categories.
Definition: util.cpp:352
void ParseParameters(int argc, const char *const argv[])
Definition: util.cpp:730
Definition: util.h:116
Definition: util.cpp:240
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: util.cpp:840
Definition: util.h:139
auto push(F &&f, Rest &&... rest) -> std::future< decltype(f(0, rest...))>
Definition: ctpl.h:152
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
Definition: utiltime.cpp:93
static FILE * fileout
We use boost::call_once() to make sure mutexDebugLog and vMsgsBeforeOpenLog are initialized in a thre...
Definition: util.cpp:192
Definition: util.h:128
Definition: util.h:123
Definition: util.h:120
Definition: util.h:118
void WarnForSectionOnlyArgs()
Log warnings for options in m_section_only_args when they are specified in the default section but no...
Definition: util.cpp:697
static boost::once_flag debugPrintInitFlag
LogPrintf() has been broken a couple of times now by well-meaning people adding mutexes in the most s...
Definition: util.cpp:181
Definition: util.h:117
Definition: util.h:278
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: util.cpp:725
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
Definition: chainparamsbase.cpp:83
static bool InterpretNegatedOption(std::string &key, std::string &val)
Interpret -nofoo as if the user supplied -foo=0.
Definition: util.cpp:657
Definition: util.cpp:134
Definition: util.h:119
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: util.cpp:824
static std::string LogThreadNameStr(const std::string &str, std::atomic_bool *fStartedNewLine)
fStartedNewLine is a state variable held by the calling context that will suppress printing of the th...
Definition: util.cpp:405
Definition: util.h:141
std::map< std::string, std::vector< std::string > > m_config_args
Definition: util.h:285
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: util.cpp:848
Definition: util.h:143
void locking_callback(int mode, int i, const char *file, int line) NO_THREAD_SAFETY_ANALYSIS
Definition: util.cpp:124
Definition: util.h:130
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
Definition: util.cpp:1434
void ReadConfigFile(const std::string &confPath)
Definition: util.cpp:1000
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
Definition: util.cpp:832
bool LockDirectory(const fs::path &directory, const std::string lockfile_name, bool probe_only)
Definition: util.cpp:477
static std::map< std::string, std::unique_ptr< boost::interprocess::file_lock > > dir_locks
A map that contains all the currently held directory locks.
Definition: util.cpp:473
Definition: util.h:127
Definition: util.h:129
Definition: util.h:125
Definition: util.h:101
std::string CopyrightHolders(const std::string &strPrefix, unsigned int nStartYear, unsigned int nEndYear)
Definition: util.cpp:1364
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
Definition: chainparamsbase.h:20
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
Definition: util.cpp:1128
uint32_t StringVersionToInt(const std::string &strVersion)
Converts version strings to 4-byte unsigned integer.
Definition: util.cpp:1379
class CInit instance_of_cinit
std::string SafeIntVersionToString(uint32_t nVersion)
Copy of the IntVersionToString, that returns "Invalid version" string instead of throwing std::bad_ca...
Definition: util.cpp:1415
Definition: util.h:122
Definition: util.h:137
Definition: util.h:111
int nWalletBackups
nWalletBackups: 1..10 - number of automatic backups to keep 0 - disabled by command-line -1 - disable...
Definition: util.cpp:102
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
Definition: util.cpp:790
bool GetLogCategory(uint64_t *f, const std::string *str)
Return true if str parses as a log category and set the flags in f.
Definition: util.cpp:291
Definition: util.h:142
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by Boost's create_directories if the requested directory exists...
Definition: util.cpp:1085
Definition: util.h:134
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: util.cpp:1151
static std::string NetworkArg(const ArgsManager &am, const std::string &arg)
Convert regular argument into the network-specific setting.
Definition: util.cpp:549
std::string FormatParagraph(const std::string &in, size_t width, size_t indent)
Format a paragraph of text to a fixed width, adding spaces for indentation to any added line...
Definition: utilstrencodings.cpp:543
Definition: util.h:109
std::string IntVersionToString(uint32_t nVersion)
Converts version as 4-byte unsigned integer to string.
Definition: util.cpp:1399
static bool UseDefaultSection(const ArgsManager &am, const std::string &arg)
Determine whether to use config settings in the default section, See also comments around ArgsManager...
Definition: util.cpp:543
static std::pair< bool, std::string > GetArg(const ArgsManager &am, const std::string &arg)
Definition: util.cpp:586
std::map< std::string, std::vector< std::string > > MapArgs
Definition: util.cpp:539
Definition: util.h:126
static std::unique_ptr< CCriticalSection[]> ppmutexOpenSSL
Init OpenSSL library multithreading support.
Definition: util.cpp:123
std::string GetPrettyExceptionStr(const std::exception_ptr &e)
Definition: stacktraces.cpp:732
void PrintExceptionContinue(const std::exception_ptr pex, const char *pszExceptionOrigin)
Definition: util.cpp:891
Definition: util.h:149
std::string GetDevNetName() const
Looks for -devnet and returns either "devnet-<name>" or simply "devnet" if no name was specified...
Definition: util.cpp:1045
Definition: util.h:121
Definition: util.h:140
static bool GetNetBoolArg(const ArgsManager &am, const std::string &net_arg, bool interpret_bool)
Definition: util.cpp:622
Definition: util.h:112
static std::string LogTimestampStr(const std::string &str, std::atomic_bool *fStartedNewLine)
fStartedNewLine is a state variable held by the calling context that will suppress printing of the ti...
Definition: util.cpp:377
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: util.cpp:808
Definition: util.h:133
Definition: util.h:135
std::atomic< bool > fReopenDebugLog(false)
void RenameThreadPool(ctpl::thread_pool &tp, const char *baseName)
Definition: util.cpp:1276
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition: util.cpp:1026
static bool InterpretBool(const std::string &strValue)
Interpret a string argument as a boolean.
Definition: util.cpp:529
Definition: ctpl.h:48
int GetNumCores()
Return the number of physical cores available on the current system.
Definition: util.cpp:1355
static void AddArgs(std::vector< std::string > &res, const MapArgs &map_args, const std::string &arg)
Find arguments in a map and add them to a vector.
Definition: util.cpp:556
Definition: util.h:113
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
Definition: util.cpp:765
Definition: util.h:144
Definition: util.h:115
Definition: util.h:136
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
Definition: util.cpp:880
std::vector< CLogCategoryActive > ListActiveLogCategories()
Returns a vector of the active log categories.
Definition: util.cpp:337
std::map< std::string, std::vector< std::string > > m_override_args
Definition: util.h:284
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:92
Wrapped mutex: supports recursive locking, but no waiting TODO: We should move away from using the re...
Definition: sync.h:94
static std::pair< bool, std::string > GetArgHelper(const MapArgs &map_args, const std::string &arg, bool getLast=false)
Return true/false if an argument is set in a map, and also return the first (or last) of the possibly...
Definition: util.cpp:567