PIVX Core  5.6.99
P2P Digital Currency
Classes | Namespaces | Functions | Variables
system.cpp File Reference
#include "util/system.h"
#include "chainparamsbase.h"
#include "random.h"
#include "support/allocators/zeroafterfree.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include <librustzcash.h>
#include <stdarg.h>
#include <thread>
#include <algorithm>
#include <fcntl.h>
#include <sched.h>
#include <sys/resource.h>
#include <sys/stat.h>
Include dependency graph for system.cpp:

Go to the source code of this file.

Classes

class  ArgsManagerHelper
 Internal helper functions for ArgsManager. More...
 

Namespaces

 util
 

Functions

bool CheckDiskSpace (const fs::path &dir, uint64_t additional_bytes)
 
bool LockDirectory (const fs::path &directory, const std::string &lockfile_name, bool probe_only)
 
void ReleaseDirectoryLocks ()
 Release all directory locks. More...
 
bool DirIsWritable (const fs::path &directory)
 
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 & ZC_GetParamsDir ()
 
void initZKSNARKS ()
 
const fs::path & GetBlocksDir ()
 
const fs::path & GetDataDir (bool fNetSpecific)
 
bool CheckDataDirOption ()
 
void ClearDatadirCache ()
 
fs::path GetConfigFile (const std::string &confPath)
 
fs::path GetMasternodeConfigFile ()
 
fs::path AbsPathForConfigVal (const fs::path &path, bool net_specific)
 
bool RenameOver (fs::path src, fs::path dest)
 
bool TryCreateDirectories (const fs::path &p)
 Ignores exceptions thrown by Boost's create_directories if the requested directory exists. More...
 
bool FileCommit (FILE *file)
 
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...
 
void runCommand (std::string strCommand)
 
void SetupEnvironment ()
 
bool SetupNetworking ()
 
void SetThreadPriority (int nPriority)
 
int GetNumCores ()
 Return the number of cores available on the current system. More...
 
int ScheduleBatchPriority (void)
 On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive. More...
 

Variables

const char *const PIVX_CONF_FILENAME = "pivx.conf"
 
const char *const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf"
 
std::atomic< bool > fMasterNode {false}
 
ArgsManager gArgs
 
CTranslationInterface translationInterface
 

Function Documentation

◆ AbsPathForConfigVal()

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

Definition at line 853 of file system.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 974 of file system.cpp.

◆ CheckDataDirOption()

bool CheckDataDirOption ( )

Definition at line 755 of file system.cpp.

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

◆ CheckDiskSpace()

bool CheckDiskSpace ( const fs::path &  dir,
uint64_t  additional_bytes 
)

Definition at line 93 of file system.cpp.

Here is the caller graph for this function:

◆ ClearDatadirCache()

void ClearDatadirCache ( )

Definition at line 761 of file system.cpp.

Here is the caller graph for this function:

◆ DirIsWritable()

bool DirIsWritable ( const fs::path &  directory)

Definition at line 140 of file system.cpp.

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

◆ FileCommit()

bool FileCommit ( FILE *  file)

Definition at line 904 of file system.cpp.

Here is the caller graph for this function:

◆ GetBlocksDir()

const fs::path& GetBlocksDir ( )

Definition at line 696 of file system.cpp.

Here is the caller graph for this function:

◆ GetConfigFile()

fs::path GetConfigFile ( const std::string &  confPath)

Definition at line 770 of file system.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 724 of file system.cpp.

Here is the caller graph for this function:

◆ GetDefaultDataDir()

fs::path GetDefaultDataDir ( )

Definition at line 533 of file system.cpp.

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

◆ GetMasternodeConfigFile()

fs::path GetMasternodeConfigFile ( )

Definition at line 776 of file system.cpp.

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

◆ GetNumCores()

int GetNumCores ( )

Return the number of cores available on the current system.

Note
This does count virtual cores, such as those provided by HyperThreading.

Definition at line 1095 of file system.cpp.

Here is the caller graph for this function:

◆ 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 499 of file system.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 503 of file system.cpp.

Here is the caller graph for this function:

◆ initZKSNARKS()

void initZKSNARKS ( )

Definition at line 624 of file system.cpp.

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

◆ LockDirectory()

bool LockDirectory ( const fs::path &  directory,
const std::string &  lockfile_name,
bool  probe_only 
)

Definition at line 110 of file system.cpp.

Here is the caller graph for this function:

◆ PrintExceptionContinue()

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

Definition at line 526 of file system.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 950 of file system.cpp.

◆ ReleaseDirectoryLocks()

void ReleaseDirectoryLocks ( )

Release all directory locks.

This is used for unit testing only, at runtime the global destructor will take care of the locks.

Definition at line 134 of file system.cpp.

Here is the caller graph for this function:

◆ RenameOver()

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

Definition at line 875 of file system.cpp.

◆ runCommand()

void runCommand ( std::string  strCommand)

Definition at line 1031 of file system.cpp.

◆ ScheduleBatchPriority()

int ScheduleBatchPriority ( void  )

On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive.

See SCHED_BATCH in sched(7) for details.

Returns
The return value of sched_setschedule(), or 1 on systems without sched_setchedule().

Definition at line 1101 of file system.cpp.

Here is the caller graph for this function:

◆ SetThreadPriority()

void SetThreadPriority ( int  nPriority)

Definition at line 1082 of file system.cpp.

◆ SetupEnvironment()

void SetupEnvironment ( )

Definition at line 1043 of file system.cpp.

Here is the caller graph for this function:

◆ SetupNetworking()

bool SetupNetworking ( )

Definition at line 1070 of file system.cpp.

Here is the caller graph for this function:

◆ TruncateFile()

bool TruncateFile ( FILE *  file,
unsigned int  length 
)

Definition at line 937 of file system.cpp.

Here is the caller graph for this function:

◆ TryCreateDirectories()

bool TryCreateDirectories ( const fs::path &  p)

Ignores exceptions thrown by Boost's create_directories 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 891 of file system.cpp.

Here is the caller graph for this function:

◆ ZC_GetParamsDir()

const fs::path& ZC_GetParamsDir ( )

Definition at line 596 of file system.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ fMasterNode

std::atomic<bool> fMasterNode {false}

Definition at line 87 of file system.cpp.

◆ gArgs

ArgsManager gArgs

Definition at line 89 of file system.cpp.

◆ PIVX_CONF_FILENAME

const char* const PIVX_CONF_FILENAME = "pivx.conf"

Definition at line 81 of file system.cpp.

◆ PIVX_MASTERNODE_CONF_FILENAME

const char* const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf"

Definition at line 82 of file system.cpp.

◆ translationInterface

CTranslationInterface translationInterface

Definition at line 91 of file system.cpp.