PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Functions | Variables
util.cpp File Reference
#include "util.h"
#include "allocators.h"
#include "chainparamsbase.h"
#include "random.h"
#include "sync.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include <stdarg.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/evp.h>
#include "pubkey.h"
#include "key.h"
#include "secp256k1.h"
#include <algorithm>
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/thread.hpp>
#include <openssl/conf.h>
#include <openssl/crypto.h>
#include <openssl/rand.h>
Include dependency graph for util.cpp:

Go to the source code of this file.

Classes

class  CInit
 

Functions

void locking_callback (int mode, int i, const char *file, int line) NO_THREAD_SAFETY_ANALYSIS
 
std::string FilterInjection (const std::string &str)
 
void ParseParameters (int argc, const char *const argv[])
 
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 PrintExceptionContinue (const std::exception *pex, const char *pszThread)
 
fs::path GetDefaultDataDir ()
 
const fs::path & GetDataDir (bool fNetSpecific)
 
void ClearDatadirCache ()
 
fs::path GetConfigFile ()
 
fs::path GetMasternodeConfigFile ()
 
void ReadConfigFile (std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet)
 
fs::path AbsPathForConfigVal (const fs::path &path, bool net_specific)
 
fs::path GetPidFile ()
 
void CreatePidFile (const fs::path &path, pid_t pid)
 
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...
 
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...
 
fs::path GetTempPath ()
 
void runCommand (std::string strCommand)
 
void SetupEnvironment ()
 
bool PointHashingSuccessively (const CPubKey &pk, const unsigned char *tweak, unsigned char *out)
 
bool SetupNetworking ()
 
void SetThreadPriority (int nPriority)
 

Variables

bool fMasterNode = false
 
std::string strMasterNodePrivKey = ""
 
std::string strMasterNodeAddr = ""
 
bool fLiteMode = false
 
bool fEnableSwiftTX = true
 
int nSwiftTXDepth = 5
 
int64_t enforceMasternodePaymentsTime = 4085657524
 
bool fSucessfullyLoaded = false
 
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
 
bool fDaemon = false
 
std::string strMiscWarning
 
class CInit instance_of_cinit
 

Function Documentation

◆ AbsPathForConfigVal()

fs::path AbsPathForConfigVal ( const fs::path &  path,
bool  net_specific 
)

Definition at line 423 of file util.cpp.

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

◆ 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:

◆ FileCommit()

void FileCommit ( FILE *  fileout)

Definition at line 477 of file util.cpp.

◆ FilterInjection()

std::string FilterInjection ( const std::string &  str)

Definition at line 167 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)

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:

◆ locking_callback()

void locking_callback ( int  mode,
int  i,
const char *  file,
int  line 
)

Definition at line 119 of file util.cpp.

◆ 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:

◆ 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

◆ enforceMasternodePaymentsTime

int64_t enforceMasternodePaymentsTime = 4085657524

Definition at line 105 of file util.cpp.

◆ fDaemon

bool fDaemon = false

Definition at line 114 of file util.cpp.

◆ fEnableSwiftTX

bool fEnableSwiftTX = true

Definition at line 102 of file util.cpp.

◆ fLiteMode

bool fLiteMode = false

Definition at line 100 of file util.cpp.

◆ fMasterNode

bool fMasterNode = false

Definition at line 97 of file util.cpp.

◆ fSucessfullyLoaded

bool fSucessfullyLoaded = false

Definition at line 106 of file util.cpp.

◆ instance_of_cinit

class CInit instance_of_cinit

◆ 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 = 5

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.

◆ strMasterNodePrivKey

std::string strMasterNodePrivKey = ""

Definition at line 98 of file util.cpp.

◆ strMiscWarning

std::string strMiscWarning

Definition at line 115 of file util.cpp.