PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Functions | Variables
util.h File Reference
#include "compat.h"
#include "fs.h"
#include "logging.h"
#include "tinyformat.h"
#include "utiltime.h"
#include "util/threadnames.h"
#include <atomic>
#include <exception>
#include <map>
#include <stdint.h>
#include <string>
#include <vector>
#include <boost/thread/exceptions.hpp>
#include "pubkey.h"
Include dependency graph for util.h:

Go to the source code of this file.

Functions

void SetupEnvironment ()
 
bool SetupNetworking ()
 
template<typename... Args>
bool error (const char *fmt, const Args &... args)
 
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)
 this function tries to raise the file descriptor limit to the requested number. More...
 
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 More...
 
bool RenameOver (fs::path src, fs::path dest)
 
bool TryCreateDirectory (const fs::path &p)
 Ignores exceptions thrown by Boost's create_directory if the requested directory exists. More...
 
fs::path GetDefaultDataDir ()
 
const fs::path & GetDataDir (bool fNetSpecific=true)
 
void ClearDatadirCache ()
 
fs::path GetConfigFile ()
 
fs::path GetMasternodeConfigFile ()
 
fs::path GetPidFile ()
 
void CreatePidFile (const fs::path &path, pid_t pid)
 
void ReadConfigFile (std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet)
 
fs::path GetTempPath ()
 
void runCommand (std::string strCommand)
 
bool IsSwitchChar (char c)
 
std::string GetArg (const std::string &strArg, const std::string &strDefault)
 Return string argument or default value. More...
 
int64_t GetArg (const std::string &strArg, int64_t nDefault)
 Return integer argument or default value. More...
 
bool GetBoolArg (const std::string &strArg, bool fDefault)
 Return boolean argument or default value. More...
 
bool SoftSetArg (const std::string &strArg, const std::string &strValue)
 Set an argument if it doesn't already have a value. More...
 
bool SoftSetBoolArg (const std::string &strArg, bool fValue)
 Set a boolean argument if it doesn't already have a value. More...
 
std::string HelpMessageGroup (const std::string &message)
 Format a string to be used as group of options in help messages. More...
 
std::string HelpMessageOpt (const std::string &option, const std::string &message)
 Format a string to be used as option description in help messages. More...
 
void SetThreadPriority (int nPriority)
 
template<typename Callable >
void TraceThread (const char *name, Callable func)
 
fs::path AbsPathForConfigVal (const boost::filesystem::path &path, bool net_specific=true)
 
bool PointHashingSuccessively (const CPubKey &pk, const unsigned char *tweak, unsigned char *out)
 

Variables

const char *const DEFAULT_DEBUGLOGFILE
 Server/client environment: argument handling, config file parsing, thread wrappers. More...
 
bool fMasterNode
 
bool fLiteMode
 
bool fEnableSwiftTX
 
int nSwiftTXDepth
 
int64_t enforceMasternodePaymentsTime
 
std::string strMasterNodeAddr
 
int keysLoaded
 
bool fSucessfullyLoaded
 
std::vector< int64_t > obfuScationDenominations
 All denominations used by obfuscation. More...
 
std::string strBudgetMode
 
std::map< std::string, std::string > mapArgs
 
std::map< std::string, std::vector< std::string > > mapMultiArgs
 
std::string strMiscWarning
 

Function Documentation

◆ AbsPathForConfigVal()

fs::path AbsPathForConfigVal ( const boost::filesystem::path &  path,
bool  net_specific = true 
)

◆ 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

Todo:
: just write one byte per block

Definition at line 531 of file util.cpp.

◆ ClearDatadirCache()

void ClearDatadirCache ( )

Definition at line 377 of file util.cpp.

◆ CreatePidFile()

void CreatePidFile ( const fs::path &  path,
pid_t  pid 
)

Definition at line 438 of file util.cpp.

Here is the call graph for this function:

◆ error()

template<typename... Args>
bool error ( const char *  fmt,
const Args &...  args 
)

Definition at line 61 of file util.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileCommit()

void FileCommit ( FILE *  fileout)

Definition at line 477 of file util.cpp.

◆ GetArg() [1/2]

std::string GetArg ( const std::string &  strArg,
const std::string &  strDefault 
)

Return string argument or default value.

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

Definition at line 241 of file util.cpp.

Here is the caller graph for this function:

◆ 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 248 of file util.cpp.

Here is the call graph for this function:

◆ GetBoolArg()

bool GetBoolArg ( const std::string &  strArg,
bool  fDefault 
)

Return boolean argument or default value.

Parameters
strArgArgument to get (e.g. "-foo")
default(true or false)
Returns
command-line argument or default value

Definition at line 255 of file util.cpp.

Here is the caller graph for this function:

◆ GetConfigFile()

fs::path GetConfigFile ( )

Definition at line 383 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDataDir()

const fs::path& GetDataDir ( bool  fNetSpecific = true)

Definition at line 349 of file util.cpp.

Here is the caller graph for this function:

◆ GetDefaultDataDir()

fs::path GetDefaultDataDir ( )

Definition at line 317 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMasternodeConfigFile()

fs::path GetMasternodeConfigFile ( )

Definition at line 389 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPidFile()

fs::path GetPidFile ( )

Definition at line 432 of file util.cpp.

Here is the call graph for this function:

◆ GetTempPath()

fs::path GetTempPath ( )

Definition at line 588 of file util.cpp.

◆ 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 282 of file util.cpp.

Here is the caller graph for this function:

◆ 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 286 of file util.cpp.

Here is the caller graph for this function:

◆ IsSwitchChar()

bool IsSwitchChar ( char  c)
inline

Definition at line 92 of file util.h.

Here is the caller graph for this function:

◆ ParseParameters()

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

Definition at line 208 of file util.cpp.

Here is the caller graph for this function:

◆ PointHashingSuccessively()

bool PointHashingSuccessively ( const CPubKey pk,
const unsigned char *  tweak,
unsigned char *  out 
)

Definition at line 619 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintExceptionContinue()

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

Definition at line 309 of file util.cpp.

Here is the caller graph for this function:

◆ 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 507 of file util.cpp.

◆ ReadConfigFile()

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

Definition at line 395 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RenameOver()

bool RenameOver ( fs::path  src,
fs::path  dest 
)

Definition at line 448 of file util.cpp.

Here is the caller graph for this function:

◆ runCommand()

void runCommand ( std::string  strCommand)

Definition at line 593 of file util.cpp.

Here is the caller graph for this function:

◆ SetThreadPriority()

void SetThreadPriority ( int  nPriority)

Definition at line 648 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetupEnvironment()

void SetupEnvironment ( )

Definition at line 600 of file util.cpp.

Here is the caller graph for this function:

◆ SetupNetworking()

bool SetupNetworking ( )

Definition at line 636 of file util.cpp.

Here is the caller graph for this function:

◆ 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 262 of file util.cpp.

Here is the caller graph for this function:

◆ 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 270 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TraceThread()

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

. and a wrapper that just calls func once

Definition at line 169 of file util.h.

Here is the call graph for this function:

◆ TruncateFile()

bool TruncateFile ( FILE *  file,
unsigned int  length 
)

Definition at line 494 of file util.cpp.

◆ TryCreateDirectory()

bool TryCreateDirectory ( const fs::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 464 of file util.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_DEBUGLOGFILE

const char* const DEFAULT_DEBUGLOGFILE

Server/client environment: argument handling, config file parsing, thread wrappers.

Definition at line 12 of file logging.cpp.

◆ enforceMasternodePaymentsTime

int64_t enforceMasternodePaymentsTime

Definition at line 105 of file util.cpp.

◆ fEnableSwiftTX

bool fEnableSwiftTX

Definition at line 102 of file util.cpp.

◆ fLiteMode

bool fLiteMode

Definition at line 100 of file util.cpp.

◆ fMasterNode

bool fMasterNode

Definition at line 97 of file util.cpp.

◆ fSucessfullyLoaded

bool fSucessfullyLoaded

Definition at line 106 of file util.cpp.

◆ keysLoaded

int keysLoaded

◆ mapArgs

std::map<std::string, std::string> mapArgs

Definition at line 111 of file util.cpp.

◆ mapMultiArgs

std::map<std::string, std::vector<std::string> > mapMultiArgs

Definition at line 112 of file util.cpp.

◆ nSwiftTXDepth

int nSwiftTXDepth

Definition at line 103 of file util.cpp.

◆ obfuScationDenominations

std::vector<int64_t> obfuScationDenominations

All denominations used by obfuscation.

Definition at line 108 of file util.cpp.

◆ strBudgetMode

std::string strBudgetMode

Definition at line 109 of file util.cpp.

◆ strMasterNodeAddr

std::string strMasterNodeAddr

Definition at line 99 of file util.cpp.

◆ strMiscWarning

std::string strMiscWarning

Definition at line 115 of file util.cpp.