Dash Core  0.12.2.1
P2P Digital Currency
util.h File Reference
#include "compat.h"
#include "tinyformat.h"
#include "utiltime.h"
#include "amount.h"
#include <exception>
#include <map>
#include <stdint.h>
#include <string>
#include <vector>
#include <boost/filesystem/path.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/thread/exceptions.hpp>

Go to the source code of this file.

Classes

class  CTranslationInterface
 

Macros

#define DBG(x)
 
#define LogPrintf(...)   LogPrint(NULL, __VA_ARGS__)
 
#define MAKE_ERROR_AND_LOG_FUNC(n)
 

Functions

std::string _ (const char *psz)
 
void SetupEnvironment ()
 
bool SetupNetworking ()
 
bool LogAcceptCategory (const char *category)
 
int LogPrintStr (const std::string &str)
 
static int LogPrint (const char *category, const char *format)
 
static bool error (const char *format)
 
void PrintExceptionContinue (const std::exception *pex, const char *pszThread)
 
void ParseParameters (int argc, const char *const argv[])
 
void FileCommit (FILE *fileout)
 
bool TruncateFile (FILE *file, unsigned int length)
 
int RaiseFileDescriptorLimit (int nMinFD)
 
void AllocateFileRange (FILE *file, unsigned int offset, unsigned int length)
 
bool RenameOver (boost::filesystem::path src, boost::filesystem::path dest)
 
bool TryCreateDirectory (const boost::filesystem::path &p)
 
boost::filesystem::path GetDefaultDataDir ()
 
const boost::filesystem::path & GetDataDir (bool fNetSpecific=true)
 
const boost::filesystem::path & GetBackupsDir ()
 
void ClearDatadirCache ()
 
boost::filesystem::path GetConfigFile ()
 
boost::filesystem::path GetMasternodeConfigFile ()
 
boost::filesystem::path GetPidFile ()
 
void CreatePidFile (const boost::filesystem::path &path, pid_t pid)
 
void ReadConfigFile (std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet)
 
boost::filesystem::path GetTempPath ()
 
void OpenDebugLog ()
 
void ShrinkDebugFile ()
 
void runCommand (const std::string &strCommand)
 
bool IsSwitchChar (char c)
 
std::string GetArg (const std::string &strArg, const std::string &strDefault)
 
int64_t GetArg (const std::string &strArg, int64_t nDefault)
 
bool GetBoolArg (const std::string &strArg, bool fDefault)
 
bool SoftSetArg (const std::string &strArg, const std::string &strValue)
 
bool SoftSetBoolArg (const std::string &strArg, bool fValue)
 
std::string HelpMessageGroup (const std::string &message)
 
std::string HelpMessageOpt (const std::string &option, const std::string &message)
 
int GetNumCores ()
 
void SetThreadPriority (int nPriority)
 
void RenameThread (const char *name)
 
std::string GetThreadName ()
 
template<typename Callable >
void TraceThread (const char *name, Callable func)
 
uint32_t StringVersionToInt (const std::string &strVersion)
 Converts version strings to 4-byte unsigned integer. More...
 
std::string IntVersionToString (uint32_t nVersion)
 Converts version as 4-byte unsigned integer to string. More...
 
std::string SafeIntVersionToString (uint32_t nVersion)
 Copy of the IntVersionToString, that returns "Invalid version" string instead of throwing std::bad_cast. More...
 

Variables

bool fMasterNode
 
bool fLiteMode
 
int nWalletBackups
 
static const bool DEFAULT_LOGTIMEMICROS = false
 
static const bool DEFAULT_LOGIPS = false
 
static const bool DEFAULT_LOGTIMESTAMPS = true
 
static const bool DEFAULT_LOGTHREADNAMES = false
 
std::map< std::string, std::string > mapArgs
 
std::map< std::string, std::vector< std::string > > mapMultiArgs
 
bool fDebug
 
bool fPrintToConsole
 
bool fPrintToDebugLog
 
bool fServer
 
std::string strMiscWarning
 
bool fLogTimestamps
 
bool fLogTimeMicros
 
bool fLogThreadNames
 
bool fLogIPs
 
volatile bool fReopenDebugLog
 
CTranslationInterface translationInterface
 
const char *const BITCOIN_CONF_FILENAME
 
const char *const BITCOIN_PID_FILENAME
 

Macro Definition Documentation

◆ DBG

◆ LogPrintf

#define LogPrintf (   ...)    LogPrint(NULL, __VA_ARGS__)

Definition at line 98 of file util.h.

Referenced by CConnman::AcceptConnection(), TorController::add_onion_cb(), CGovernanceManager::AddGovernanceObject(), CKeyHolderStorage::AddKey(), AddLocal(), CGovernanceTriggerManager::AddNewTrigger(), CPrivateSendServer::AddScriptSig(), CWallet::AddToWallet(), CWallet::AddToWalletIfInvolvingMe(), CPrivateSendServer::AddUserToExistingSession(), AdvertiseLocal(), AppInit2(), CNode::AskFor(), CMasternodeMan::AskForMN(), TorController::auth_cb(), TorController::authchallenge_cb(), AutoBackupWallet(), BackupWallet(), CConnman::BindListenPort(), BitcoinMiner(), CalculateNextWorkRequired(), CDBWrapper::CDBWrapper(), CGovernancePayment::CGovernancePayment(), CWallet::ChangeWalletPassphrase(), CPrivateSendServer::ChargeFees(), CPrivateSendServer::ChargeRandomFees(), CMasternode::Check(), CAddrMan::Check(), CInstantSend::CheckAndRemove(), CMasternodeMan::CheckAndRemove(), CMasternodePayments::CheckAndRemove(), CMasternodePing::CheckAndUpdate(), CPrivateSendClient::CheckAutomaticBackup(), CheckBlock(), CheckForkWarningConditions(), CMasternodeMan::CheckMnbAndUpdateMasternodeList(), CGovernanceObject::CheckOrphanVotes(), CMasternodeBroadcast::CheckOutpoint(), CPrivateSendClient::CheckPoolStateUpdate(), CGovernanceManager::CheckPostponedObjects(), CMasternodeMan::CheckSameAddr(), CMasternodePing::CheckSignature(), CSporkMessage::CheckSignature(), CTxLockVote::CheckSignature(), CDarksendQueue::CheckSignature(), CGovernanceObject::CheckSignature(), CDarksendBroadcastTx::CheckSignature(), CMasternodeBroadcast::CheckSignature(), CleanupBlockRevFiles(), CPrivateSendServer::CommitFinalTransaction(), CWallet::CommitTransaction(), CPrivateSendClient::CompletedTransaction(), TorControlConnection::Connect(), TorController::connected_cb(), CConnman::ConnectNode(), ConnectSocketDirectly(), CWallet::ConvertList(), CGovernanceVoting::ConvertVoteSignal(), CMasternodeBroadcast::Create(), CPrivateSendClient::CreateDenominated(), CInstantSend::CreateEmptyTxLockCandidate(), CreateNewBlock(), CPrivateSendServer::CreateNewSession(), CSuperblockManager::CreateSuperblock(), CInstantSend::CreateTxLockCandidate(), DecryptAES256(), DeleteAuthCookie(), DisconnectBlocks(), Discover(), CPrivateSendClient::DoAutomaticDenominating(), CMasternodeMan::DsegUpdate(), CFlatDB< T >::Dump(), EncryptAES256(), CWallet::EncryptWallet(), CDBEnv::EnvShutdown(), CSporkManager::ExecuteSpork(), CDBWrapper::Exists(), CMasternodePayments::FillBlockPayee(), FindBlockPos(), CMasternodeMan::FindRandomNotInVec(), FindUndoPos(), CWalletDB::FindWalletTx(), GenerateAuthCookie(), CWallet::GenerateNewHDChain(), CWalletTx::GetAmounts(), GetBackupsDir(), CWallet::GetBudgetSystemCollateralTX(), CCoinsViewErrorCatcher::GetCoins(), CMasternodeMan::GetMasternodeByRank(), CWallet::GetMasternodeOutpointAndKeys(), CMasternodeMan::GetMasternodeRank(), CMasternodeMan::GetMasternodeRanks(), CMasternodeMan::GetNextMasternodeInQueueForPayment(), CWallet::GetOutpointAndKeysFromOutput(), GetRandBytes(), GetTempPath(), gobject(), HandleError(), HTTPBindAddresses(), HTTPReq_JSONRPC(), importelectrumwallet(), importwallet(), InitBlockIndex(), InitHTTPServer(), InitLogging(), InitMessage(), CGovernanceManager::InitOnLoad(), InitParameterInteraction(), InitRPCAuthentication(), InterruptTorControl(), InvalidChainFound(), IsBlockPayeeValid(), IsBlockValueValid(), CGovernanceObject::IsCollateralValid(), CPrivateSend::IsCollateralValid(), CPrivateSendServer::IsOutputsCompatibleWithSessionDenom(), CSuperblockManager::IsSuperblockTriggered(), CMasternodeBlockPayees::IsTransactionValid(), CMessageHeader::IsValid(), CGovernanceVote::IsValid(), CMasternodePaymentVote::IsValid(), CTxLockVote::IsValid(), CSuperblock::IsValid(), CPrivateSendClient::JoinExistingQueue(), CKeyHolderStorage::KeepAll(), CWallet::KeepKey(), libevent_log_cb(), CFlatDB< T >::Load(), LoadBlockIndexDB(), CWallet::LoadCScript(), CGovernanceObject::LoadData(), LoadExternalBlockFile(), CWalletDB::LoadWallet(), LogAcceptCategory(), CPrivateSendClient::MakeCollateralAmounts(), CActiveMasternode::ManageState(), CActiveMasternode::ManageStateInitial(), CActiveMasternode::ManageStateLocal(), CActiveMasternode::ManageStateRemote(), CGovernanceManager::MasternodeRateCheck(), Misbehaving(), CWallet::NewKeyPool(), noui_InitMessage(), noui_ThreadSafeMessageBox(), CDBEnv::Open(), OpenDiskFile(), CSuperblock::ParsePaymentSchedule(), CPrivateSendClient::PrepareDenominate(), PrepareShutdown(), PrintExceptionContinue(), CTxMemPool::PrioritiseTransaction(), OverviewPage::privateSendStatus(), CMasternodePayments::ProcessBlock(), ProcessBlockFound(), ProcessGetData(), CPrivateSendServer::ProcessMessage(), CMasternodeSync::ProcessMessage(), CPrivateSendClient::ProcessMessage(), CMasternodeMan::ProcessMessage(), CMasternodePayments::ProcessMessage(), CGovernanceManager::ProcessMessage(), ProcessMessage(), ProcessMessages(), ProcessNewBlock(), CSporkManager::ProcessSpork(), CMasternodeSync::ProcessTick(), CInstantSend::ProcessTxLockRequest(), CInstantSend::ProcessTxLockVote(), CMasternodeMan::ProcessVerifyBroadcast(), CMasternodeMan::ProcessVerifyReply(), CGovernanceObject::ProcessVote(), CGovernanceManager::ProcessVote(), TorController::protocolinfo_cb(), RandAddSeedPerfmon(), CFlatDB< T >::Read(), CDBWrapper::Read(), TorControlConnection::readcb(), CTxMemPool::ReadFeeEstimates(), TorController::Reconnect(), CWalletDB::Recover(), CPrivateSendServer::RelayStatus(), CWalletTx::RelayWalletTransaction(), RemoveLocal(), ReprocessBlocks(), CMasternodePayments::RequestLowDataPaymentBlocks(), CWallet::ResendWalletTransactions(), CWallet::ReserveKeyFromKeyPool(), CInstantSend::ResolveConflicts(), CKeyHolderStorage::ReturnAll(), CWallet::ReturnKey(), CDB::Rewrite(), runCommand(), CDBEnv::Salvage(), CWallet::ScanForWalletTransactions(), CPrivateSendClient::SendDenominate(), CActiveMasternode::SendMasternodePing(), SendMessages(), CMasternodeMan::SendVerifyReply(), CMasternodeMan::SendVerifyRequest(), CConnman::SetMaxOutboundTarget(), CMerkleTx::SetMerkleBranch(), CSporkManager::SetPrivKey(), CPrivateSendServer::SetState(), CPrivateSendClient::SetState(), Shutdown(), CDarkSendRelay::Sign(), CMasternodePing::Sign(), CSporkMessage::Sign(), CGovernanceVote::Sign(), CMasternodePaymentVote::Sign(), CTxLockVote::Sign(), CDarksendQueue::Sign(), CGovernanceObject::Sign(), CDarksendBroadcastTx::Sign(), CMasternodeBroadcast::Sign(), CPrivateSendClient::SignFinalTransaction(), CMasternodePing::SimpleCheck(), CMasternodeBroadcast::SimpleCheck(), CConnman::SocketSendData(), Socks5(), CConnman::Start(), StartHTTPServer(), CPrivateSendClient::StartNewQueue(), StartTorControl(), CConnman::Stop(), StopHTTPServer(), CPrivateSendClient::SubmitDenominate(), CMasternodeSync::SwitchToNextAsset(), CMasternodePayments::Sync(), CGovernanceManager::Sync(), CConnman::ThreadDNSAddressSeed(), ThreadImport(), CConnman::ThreadOpenConnections(), ThreadSendAlert(), CConnman::ThreadSocketHandler(), CWallet::TopUpKeyPool(), TorController::TorController(), TraceThread(), UnlinkPrunedFiles(), CCryptoKeyStore::Unlock(), CWallet::Unlock(), CMasternodeBroadcast::Update(), CGovernanceManager::UpdateCachesAndClean(), CMasternode::UpdateFromNewBroadcast(), CMasternodeMan::UpdateMasternodeList(), UpdateTip(), CWallet::Verify(), CVerifyDB::VerifyDB(), CDarkSendRelay::VerifyMessage(), CInstantSend::Vote(), CFlatDB< T >::Write(), CTxMemPool::WriteFeeEstimates(), and HTTPRequest::~HTTPRequest().

◆ MAKE_ERROR_AND_LOG_FUNC

#define MAKE_ERROR_AND_LOG_FUNC (   n)
Value:
\
template<TINYFORMAT_ARGTYPES(n)> \
static inline int LogPrint(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \
{ \
if(!LogAcceptCategory(category)) return 0; \
} \ \
template<TINYFORMAT_ARGTYPES(n)> \
static inline bool error(const char* format, TINYFORMAT_VARARGS(n)) \
{ \
LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \
return false; \
}
#define TINYFORMAT_PASSARGS(n)
Definition: tinyformat.h:323
#define TINYFORMAT_VARARGS(n)
Definition: tinyformat.h:322
static int LogPrint(const char *category, const char *format)
Definition: util.h:126
static bool error(const char *format)
Definition: util.h:131
bool LogAcceptCategory(const char *category)
Definition: util.cpp:247
int LogPrintStr(const std::string &str)
Definition: util.cpp:342

When we switch to C++11, this can be switched to variadic templates instead of this macro-based construction (see tinyformat.h).

Definition at line 104 of file util.h.

Function Documentation

◆ _()

◆ 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 is advisory, and the range specified in the arguments will never contain live data

Definition at line 757 of file util.cpp.

Referenced by FindBlockPos(), and FindUndoPos().

◆ ClearDatadirCache()

void ClearDatadirCache ( )

Definition at line 605 of file util.cpp.

Referenced by ReadConfigFile().

◆ CreatePidFile()

void CreatePidFile ( const boost::filesystem::path &  path,
pid_t  pid 
)

Definition at line 664 of file util.cpp.

Referenced by AppInit2().

◆ error()

◆ FileCommit()

void FileCommit ( FILE *  fileout)

Definition at line 705 of file util.cpp.

Referenced by FlushBlockFile(), CAddrDB::Write(), and CBanDB::Write().

◆ GetArg() [1/2]

◆ GetArg() [2/2]

int64_t GetArg ( const std::string &  strArg,
int64_t  nDefault 
)

Return integer argument or default value

Parameters
strArgArgument to get (e.g. "-foo")
default(e.g. 1)
Returns
command-line argument (0 if invalid number) or default value

Definition at line 448 of file util.cpp.

◆ GetBackupsDir()

const boost::filesystem::path& GetBackupsDir ( )

Definition at line 580 of file util.cpp.

Referenced by AutoBackupWallet(), and GUIUtil::showBackups().

◆ GetBoolArg()

◆ GetConfigFile()

boost::filesystem::path GetConfigFile ( )

Definition at line 611 of file util.cpp.

Referenced by AppInit2(), CallRPC(), GUIUtil::openConfigfile(), and ReadConfigFile().

◆ GetDataDir()

◆ GetDefaultDataDir()

boost::filesystem::path GetDefaultDataDir ( )

Definition at line 516 of file util.cpp.

Referenced by AppInit2(), GetDataDir(), and Intro::getDefaultDataDirectory().

◆ GetMasternodeConfigFile()

boost::filesystem::path GetMasternodeConfigFile ( )

Definition at line 620 of file util.cpp.

Referenced by AppInit2(), GUIUtil::openMNConfigfile(), and CMasternodeConfig::read().

◆ GetNumCores()

int GetNumCores ( )

Return the number of physical cores available on the current system.

Note
This does not count virtual cores, such as those provided by HyperThreading when boost is newer than 1.56.

Definition at line 948 of file util.cpp.

Referenced by AppInit2(), GenerateBitcoins(), HelpMessage(), and OptionsDialog::OptionsDialog().

◆ GetPidFile()

boost::filesystem::path GetPidFile ( )

Definition at line 657 of file util.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ GetTempPath()

boost::filesystem::path GetTempPath ( )

Definition at line 844 of file util.cpp.

◆ GetThreadName()

std::string GetThreadName ( )

Definition at line 889 of file util.cpp.

Referenced by LogAcceptCategory(), and LogThreadNameStr().

◆ HelpMessageGroup()

std::string HelpMessageGroup ( const std::string &  message)

Format a string to be used as group of options in help messages

Parameters
messageGroup name (e.g. "RPC server options:")
Returns
the formatted string

Definition at line 482 of file util.cpp.

Referenced by AppendParamsHelpMessages(), AppInitRawTx(), HelpMessage(), HelpMessageCli(), and HelpMessageDialog::HelpMessageDialog().

◆ HelpMessageOpt()

std::string HelpMessageOpt ( const std::string &  option,
const std::string &  message 
)

Format a string to be used as option description in help messages

Parameters
optionOption message (e.g. "-rpcuser=<user>")
messageOption description (e.g. "Username for JSON-RPC connections")
Returns
the formatted string

Definition at line 486 of file util.cpp.

Referenced by AppendParamsHelpMessages(), AppInitRawTx(), HelpMessage(), HelpMessageCli(), and HelpMessageDialog::HelpMessageDialog().

◆ IntVersionToString()

std::string IntVersionToString ( uint32_t  nVersion)

Converts version as 4-byte unsigned integer to string.

Parameters
nVersion4-byte unsigned integer, most significant byte is always 0
Returns
version string in "x.x.x" format (last 3 bytes as version parts) Throws std::bad_cast if format doesn match.

Definition at line 978 of file util.cpp.

Referenced by SafeIntVersionToString().

◆ IsSwitchChar()

bool IsSwitchChar ( char  c)
inline

Definition at line 164 of file util.h.

Referenced by AppInit(), CommandLineRawTx(), and CommandLineRPC().

◆ LogAcceptCategory()

bool LogAcceptCategory ( const char *  category)

Return true if log accepts specified category

Definition at line 247 of file util.cpp.

Referenced by InitHTTPServer(), LogPrint(), and CWallet::SelectCoinsGrouppedByAddresses().

◆ LogPrint()

static int LogPrint ( const char *  category,
const char *  format 
)
inlinestatic

Zero-arg versions of logging and error, these are not covered by TINYFORMAT_FOREACH_ARGNUM

Definition at line 126 of file util.h.

Referenced by CConnman::AcceptConnection(), CMasternodeSync::AcceptedBlockHeader(), AcceptToMemoryPool(), AcceptToMemoryPoolWorker(), CMasternodeMan::Add(), CAddrMan::Add(), TorController::add_onion_cb(), CPrivateSendServer::AddEntry(), CGovernanceManager::AddGovernanceObject(), AddOrphanTx(), CPrivateSendServer::AddScriptSig(), AddTimeData(), CNode::AskFor(), TorController::auth_cb(), TorController::authchallenge_cb(), CCoinsViewDB::BatchWrite(), CMasternodeSync::BumpAssetLastTime(), CMasternodeMan::Check(), CMasternode::Check(), CTxMemPool::check(), CInstantSend::CheckAndRemove(), CMasternodeMan::CheckAndRemove(), CMasternodePayments::CheckAndRemove(), CMasternodePing::CheckAndUpdate(), CPrivateSendClient::CheckAutomaticBackup(), CPrivateSend::CheckDSTXes(), CPrivateSendServer::CheckForCompleteQueue(), CMasternodeMan::CheckMnbAndUpdateMasternodeList(), CMasternodeBroadcast::CheckOutpoint(), CPrivateSendServer::CheckPool(), CPrivateSendClient::CheckPool(), CMasternodePayments::CheckPreviousBlockVotes(), CMasternodeBroadcast::CheckSignature(), CPrivateSendServer::CheckTimeout(), CPrivateSendClient::CheckTimeout(), CGovernanceTriggerManager::CleanAndRemove(), CGovernanceManager::Clear(), CNode::CloseSocketDisconnect(), CNode::CNode(), CPrivateSendServer::CommitFinalTransaction(), CGovernanceManager::ConfirmInventoryRequest(), ConnectBlock(), CConnman::ConnectNode(), ConnectSocketDirectly(), ConnectTip(), CMasternodeBroadcast::Create(), CPrivateSendClient::CreateDenominated(), CPrivateSendServer::CreateFinalTransaction(), CPrivateSendServer::CreateNewSession(), CSuperblockManager::CreateSuperblock(), CInstantSend::CreateTxLockCandidate(), CSuperblock::CSuperblock(), DebugMessageHandler(), TorController::disconnected_cb(), DisconnectTip(), CPrivateSendClient::DoAutomaticDenominating(), CMasternodeMan::DoFullVerificationStep(), CKeePassIntegrator::doHTTPPost(), CMasternodeMan::DsegUpdate(), CConnman::DumpAddresses(), CConnman::DumpBanlist(), EraseOrphansFor(), TxConfirmStats::EstimateMedianVal(), TorControlConnection::eventcb(), CSporkManager::ExecuteSpork(), FillBlockPayments(), FindFilesToPrune(), CMasternodeMan::FindRandomNotInVec(), CDBEnv::Flush(), CMasternodeBlockPayees::GetBestPayee(), CSuperblock::GetPaymentsLimit(), CWallet::GetRealOutpointPrivateSendRounds(), CSuperblockManager::GetRequiredPaymentsString(), CSporkManager::GetSporkIDByName(), CSporkManager::GetSporkNameByID(), CSporkManager::GetSporkValue(), CAddrMan::Good_(), CMasternodeBlockPayees::HasPayeeWithVotes(), http_reject_request_cb(), http_request_cb(), HTTPBindAddresses(), InitHTTPAllowList(), InitHTTPServer(), CZMQNotificationInterface::Initialize(), CZMQAbstractPublishNotifier::Initialize(), InterruptHTTPRPC(), InterruptHTTPServer(), InterruptRPC(), CPrivateSendServer::IsAcceptableDenomAndCollateral(), IsBlockPayeeValid(), IsBlockValueValid(), CPrivateSend::IsCollateralValid(), CPrivateSendServer::IsInputScriptSigValid(), CSporkManager::IsSporkActive(), CSuperblockManager::IsSuperblockTriggered(), CMasternodeBlockPayees::IsTransactionValid(), CGovernanceVote::IsValid(), CTxLockRequest::IsValid(), CMasternodePaymentVote::IsValid(), CTxLockVote::IsValid(), CSuperblock::IsValid(), CPrivateSendClient::JoinExistingQueue(), libevent_log_cb(), LimitMempoolSize(), LoadExternalBlockFile(), CInstantSend::LockTransactionInputs(), CPrivateSendClient::MakeCollateralAmounts(), CDBEnv::MakeMock(), CActiveMasternode::ManageState(), CActiveMasternode::ManageStateInitial(), CActiveMasternode::ManageStateLocal(), CActiveMasternode::ManageStateRemote(), CPrivateSendClient::NewBlock(), TxConfirmStats::NewTx(), CZMQPublishHashBlockNotifier::NotifyBlock(), CZMQPublishRawBlockNotifier::NotifyBlock(), CMasternodeSync::NotifyHeaderTip(), CZMQPublishHashTransactionNotifier::NotifyTransaction(), CZMQPublishRawTransactionNotifier::NotifyTransaction(), CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(), CZMQPublishRawTransactionLockNotifier::NotifyTransactionLock(), OnRPCStopped(), JSONRequest::parse(), CAlert::ProcessAlert(), CMasternodePayments::ProcessBlock(), CBlockPolicyEstimator::processBlock(), CBlockPolicyEstimator::processBlockTx(), ProcessGetData(), CPrivateSendServer::ProcessMessage(), CPrivateSendClient::ProcessMessage(), CMasternodeMan::ProcessMessage(), CMasternodePayments::ProcessMessage(), CGovernanceManager::ProcessMessage(), ProcessMessage(), CSporkManager::ProcessSpork(), CMasternodeSync::ProcessTick(), CBlockPolicyEstimator::processTransaction(), CInstantSend::ProcessTxLockRequest(), CInstantSend::ProcessTxLockVote(), CMasternodeMan::ProcessVerifyBroadcast(), CMasternodeMan::ProcessVerifyReply(), CGovernanceObject::ProcessVote(), CGovernanceManager::ProcessVote(), TorController::protocolinfo_cb(), CNode::PushInventory(), CConnman::PushMessage(), RandAddSeedPerfmon(), TxConfirmStats::Read(), TorControlConnection::readcb(), CNode::ReceiveMsgBytes(), RegisterHTTPHandler(), CPrivateSendServer::RelayCompletedTransaction(), CPrivateSendServer::RelayFinalTransaction(), TxConfirmStats::removeTx(), CBlockPolicyEstimator::removeTx(), CGovernanceManager::RequestGovernanceObject(), CGovernanceManager::RequestGovernanceObjectVotes(), CGovernanceManager::RequestOrphanObjects(), CInstantSend::ResolveConflicts(), CKeePassIntegrator::rpcAssociate(), CKeePassIntegrator::rpcGetLogins(), RPCRunLater(), CKeePassIntegrator::rpcSetLogin(), CKeePassIntegrator::rpcTestAssociation(), CWallet::SelectCoinsGrouppedByAddresses(), CWallet::SelectCoinsMinConf(), CPrivateSendClient::SendDenominate(), CActiveMasternode::SendMasternodePing(), SendMessages(), CMasternodeMan::SendVerifyRequest(), CGovernanceObject::SerializationOp(), CConnman::SetNetworkActive(), CPrivateSendServer::SetState(), CZMQNotificationInterface::Shutdown(), CZMQAbstractPublishNotifier::Shutdown(), CGovernanceObject::Sign(), CPrivateSendClient::SignFinalTransaction(), CMasternodePing::SimpleCheck(), Socks5(), CConnman::Start(), StartHTTPRPC(), StartHTTPServer(), StartRPC(), StopHTTPRPC(), StopHTTPServer(), StopRPC(), CPrivateSendClient::SubmitDenominate(), CConnman::SweepBanned(), CGovernanceManager::Sync(), CInstantSend::SyncTransaction(), CPrivateSend::SyncTransaction(), ThreadFlushWalletDB(), ThreadHTTP(), CConnman::ThreadMnbRequestConnections(), CConnman::ThreadOpenConnections(), CConnman::ThreadSocketHandler(), OverviewPage::togglePrivateSend(), TorController::TorController(), CTxMemPool::TrimToSize(), CInstantSend::TryToFinalizeLockCandidate(), UnregisterHTTPHandler(), CAddrMan::Unserialize(), CGovernanceManager::UpdateCachesAndClean(), CGovernanceManager::UpdateCurrentWatchdog(), CMasternodeSync::UpdatedBlockTip(), CPrivateSendClient::UpdatedBlockTip(), CMasternodePayments::UpdatedBlockTip(), CMasternodeMan::UpdatedBlockTip(), CGovernanceManager::UpdatedBlockTip(), CMasternode::UpdateLastPaid(), CInstantSend::UpdateLockedTransaction(), CInstantSend::Vote(), and zmqError().

◆ LogPrintStr()

int LogPrintStr ( const std::string &  str)

Send a string to the log output

Definition at line 342 of file util.cpp.

Referenced by error(), and LogPrint().

◆ OpenDebugLog()

void OpenDebugLog ( )

Definition at line 226 of file util.cpp.

Referenced by AppInit2().

◆ ParseParameters()

void ParseParameters ( int  argc,
const char *const  argv[] 
)

Definition at line 406 of file util.cpp.

Referenced by AppInit(), AppInitRawTx(), AppInitRPC(), and main().

◆ PrintExceptionContinue()

void PrintExceptionContinue ( const std::exception *  pex,
const char *  pszThread 
)

◆ RaiseFileDescriptorLimit()

int RaiseFileDescriptorLimit ( int  nMinFD)

this function tries to raise the file descriptor limit to the requested number. It returns the actual file descriptor limit (which may be more or less than nMinFD)

Definition at line 734 of file util.cpp.

Referenced by AppInit2().

◆ ReadConfigFile()

void ReadConfigFile ( std::map< std::string, std::string > &  mapSettingsRet,
std::map< std::string, std::vector< std::string > > &  mapMultiSettingsRet 
)

◆ RenameOver()

bool RenameOver ( boost::filesystem::path  src,
boost::filesystem::path  dest 
)

Definition at line 675 of file util.cpp.

Referenced by ThreadImport(), CAddrDB::Write(), and CBanDB::Write().

◆ RenameThread()

◆ runCommand()

void runCommand ( const std::string &  strCommand)

◆ SafeIntVersionToString()

std::string SafeIntVersionToString ( uint32_t  nVersion)

Copy of the IntVersionToString, that returns "Invalid version" string instead of throwing std::bad_cast.

Parameters
nVersion4-byte unsigned integer, most significant byte is always 0
Returns
version string in "x.x.x" format (last 3 bytes as version parts) or "Invalid version" if can't cast the given value

Definition at line 994 of file util.cpp.

Referenced by masternodelist().

◆ SetThreadPriority()

void SetThreadPriority ( int  nPriority)

Definition at line 935 of file util.cpp.

Referenced by BitcoinMiner(), SetThreadPriority(), and CConnman::ThreadMessageHandler().

◆ SetupEnvironment()

void SetupEnvironment ( )

Definition at line 904 of file util.cpp.

Referenced by main().

◆ SetupNetworking()

bool SetupNetworking ( )

Definition at line 923 of file util.cpp.

Referenced by AppInit2(), and main().

◆ ShrinkDebugFile()

void ShrinkDebugFile ( )

Definition at line 799 of file util.cpp.

Referenced by AppInit2().

◆ SoftSetArg()

bool SoftSetArg ( const std::string &  strArg,
const std::string &  strValue 
)

Set an argument if it doesn't already have a value

Parameters
strArgArgument to set (e.g. "-foo")
strValueValue (e.g. "1")
Returns
true if argument gets set, false if it already had a value

Definition at line 462 of file util.cpp.

Referenced by OptionsModel::Init(), InitParameterInteraction(), Intro::pickDataDirectory(), and SoftSetBoolArg().

◆ SoftSetBoolArg()

bool SoftSetBoolArg ( const std::string &  strArg,
bool  fValue 
)

Set a boolean argument if it doesn't already have a value

Parameters
strArgArgument to set (e.g. "-foo")
fValueValue (e.g. false)
Returns
true if argument gets set, false if it already had a value

Definition at line 470 of file util.cpp.

Referenced by AppInit(), OptionsModel::Init(), InitParameterInteraction(), and CWalletDB::LoadWallet().

◆ StringVersionToInt()

uint32_t StringVersionToInt ( const std::string &  strVersion)

Converts version strings to 4-byte unsigned integer.

Parameters
strVersionversion in "x.x.x" format (decimal digits only)
Returns
4-byte unsigned integer, most significant byte is always 0 Throws std::bad_cast if format doesn match.

Definition at line 958 of file util.cpp.

Referenced by sentinelping().

◆ TraceThread()

template<typename Callable >
void TraceThread ( const char *  name,
Callable  func 
)

.. and a wrapper that just calls func once

Definition at line 249 of file util.h.

Referenced by CConnman::Start(), and StartTorControl().

◆ TruncateFile()

bool TruncateFile ( FILE *  file,
unsigned int  length 
)

Definition at line 722 of file util.cpp.

Referenced by FlushBlockFile().

◆ TryCreateDirectory()

bool TryCreateDirectory ( const boost::filesystem::path &  p)

Ignores exceptions thrown by Boost's create_directory if the requested directory exists. Specifically handles case where path p exists, but it wasn't possible for the user to write to the parent directory.

Definition at line 691 of file util.cpp.

Referenced by CDBWrapper::CDBWrapper(), CDBEnv::Open(), and Intro::pickDataDirectory().

Variable Documentation

◆ BITCOIN_CONF_FILENAME

const char* const BITCOIN_CONF_FILENAME

Definition at line 119 of file util.cpp.

Referenced by GetConfigFile(), getgenerate(), HelpMessage(), and HelpMessageCli().

◆ BITCOIN_PID_FILENAME

const char* const BITCOIN_PID_FILENAME

Definition at line 120 of file util.cpp.

Referenced by GetPidFile(), and HelpMessage().

◆ DEFAULT_LOGIPS

const bool DEFAULT_LOGIPS = false
static

Definition at line 51 of file util.h.

Referenced by HelpMessage(), and InitLogging().

◆ DEFAULT_LOGTHREADNAMES

const bool DEFAULT_LOGTHREADNAMES = false
static

Definition at line 53 of file util.h.

Referenced by HelpMessage(), and InitLogging().

◆ DEFAULT_LOGTIMEMICROS

const bool DEFAULT_LOGTIMEMICROS = false
static

Definition at line 50 of file util.h.

Referenced by HelpMessage(), and InitLogging().

◆ DEFAULT_LOGTIMESTAMPS

const bool DEFAULT_LOGTIMESTAMPS = true
static

Definition at line 52 of file util.h.

Referenced by HelpMessage(), and InitLogging().

◆ fDebug

◆ fLiteMode

◆ fLogIPs

bool fLogIPs

Definition at line 133 of file util.cpp.

Referenced by CNode::CNode(), InitLogging(), and ProcessMessage().

◆ fLogThreadNames

bool fLogThreadNames

Definition at line 132 of file util.cpp.

Referenced by InitLogging(), and LogThreadNameStr().

◆ fLogTimeMicros

bool fLogTimeMicros

Definition at line 131 of file util.cpp.

Referenced by InitLogging(), and LogTimestampStr().

◆ fLogTimestamps

bool fLogTimestamps

Definition at line 130 of file util.cpp.

Referenced by AppInit2(), InitLogging(), and LogTimestampStr().

◆ fMasterNode

bool fMasterNode

Definition at line 108 of file util.cpp.

Referenced by CConnman::AcceptConnection(), CPrivateSendServer::AddEntry(), CPrivateSendServer::AddUserToExistingSession(), AppInit2(), CWallet::AvailableCoins(), CPrivateSendServer::ChargeFees(), CPrivateSendServer::ChargeRandomFees(), CMasternode::Check(), CPrivateSendServer::CheckForCompleteQueue(), CMasternodeMan::CheckMnbAndUpdateMasternodeList(), CMasternodeBroadcast::CheckOutpoint(), CPrivateSendServer::CheckPool(), CPrivateSendClient::CheckPoolStateUpdate(), CPrivateSendServer::CheckTimeout(), CPrivateSendClient::CheckTimeout(), CPrivateSendServer::CommitFinalTransaction(), CPrivateSendClient::CompletedTransaction(), CPrivateSendServer::CreateNewSession(), CPrivateSendClient::DoAutomaticDenominating(), getpoolinfo(), CPrivateSendServer::IsAcceptableDenomAndCollateral(), CMasternodePaymentVote::IsValid(), CActiveMasternode::ManageState(), masternode(), OverviewPage::OverviewPage(), privatesend(), CMasternodePayments::ProcessBlock(), CPrivateSendServer::ProcessMessage(), CPrivateSendClient::ProcessMessage(), CMasternodeSync::ProcessTick(), CGovernanceManager::RequestGovernanceObjectVotes(), CWallet::SelectCoinsDark(), CWallet::SelectCoinsGrouppedByAddresses(), CPrivateSendClient::SendDenominate(), CMasternodeMan::SendVerifyReply(), CPrivateSendServer::SetState(), CDarksendQueue::Sign(), CDarksendBroadcastTx::Sign(), CPrivateSendClient::SignFinalTransaction(), CGovernanceManager::Sync(), ThreadCheckPrivateSend(), CMasternodeBroadcast::Update(), CMasternodeMan::UpdatedBlockTip(), CMasternode::UpdateFromNewBroadcast(), CMasternodeMan::UpdateLastPaid(), CInstantSend::Vote(), and OverviewPage::~OverviewPage().

◆ fPrintToConsole

bool fPrintToConsole

Definition at line 125 of file util.cpp.

Referenced by InitLogging(), and LogPrintStr().

◆ fPrintToDebugLog

bool fPrintToDebugLog

Definition at line 126 of file util.cpp.

Referenced by AppInit2(), InitLogging(), LogPrintStr(), and main().

◆ fReopenDebugLog

volatile bool fReopenDebugLog

Definition at line 134 of file util.cpp.

Referenced by HandleSIGHUP(), and LogPrintStr().

◆ fServer

bool fServer

Definition at line 128 of file util.cpp.

Referenced by AppInit2().

◆ mapArgs

◆ mapMultiArgs

◆ nWalletBackups

int nWalletBackups

nWalletBackups: 1..10 - number of automatic backups to keep 0 - disabled by command-line -1 - disabled because of some error during run-time -2 - disabled because wallet was locked and we were not able to replenish keypool

Definition at line 117 of file util.cpp.

Referenced by AppInit2(), AutoBackupWallet(), CPrivateSendClient::CheckAutomaticBackup(), OverviewPage::DisablePrivateSendCompletely(), HelpMessage(), CWallet::KeepKey(), OverviewPage::OverviewPage(), OverviewPage::privateSendStatus(), and CWallet::Unlock().

◆ strMiscWarning

std::string strMiscWarning

◆ translationInterface

CTranslationInterface translationInterface

Definition at line 135 of file util.cpp.

Referenced by _(), and main().