Bitcoin Core  0.18.99
P2P Digital Currency
Classes | Namespaces | Enumerations | Functions | Variables
system.h File Reference
#include <attributes.h>
#include <compat.h>
#include <compat/assumptions.h>
#include <fs.h>
#include <logging.h>
#include <sync.h>
#include <util/threadnames.h>
#include <tinyformat.h>
#include <util/memory.h>
#include <util/time.h>
#include <atomic>
#include <exception>
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
#include <boost/thread/condition_variable.hpp>
Include dependency graph for system.h:

Go to the source code of this file.

Classes

struct  SectionInfo
 
class  ArgsManager
 
struct  ArgsManager::Arg
 

Namespaces

 util
 

Enumerations

enum  OptionsCategory {
  OptionsCategory::OPTIONS, OptionsCategory::CONNECTION, OptionsCategory::WALLET, OptionsCategory::WALLET_DEBUG_TEST,
  OptionsCategory::ZMQ, OptionsCategory::DEBUG_TEST, OptionsCategory::CHAINPARAMS, OptionsCategory::NODE_RELAY,
  OptionsCategory::BLOCK_CREATION, OptionsCategory::RPC, OptionsCategory::GUI, OptionsCategory::COMMANDS,
  OptionsCategory::REGISTER_COMMANDS, OptionsCategory::HIDDEN
}
 

Functions

int64_t GetStartupTime ()
 Server/client environment: argument handling, config file parsing, thread wrappers, startup time. More...
 
std::string _ (const char *psz)
 Translation function. More...
 
void SetupEnvironment ()
 
bool SetupNetworking ()
 
template<typename... Args>
bool error (const char *fmt, const Args &... args)
 
void PrintExceptionContinue (const std::exception *pex, const char *pszThread)
 
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...
 
bool RenameOver (fs::path src, fs::path dest)
 
bool LockDirectory (const fs::path &directory, const std::string lockfile_name, bool probe_only=false)
 
void UnlockDirectory (const fs::path &directory, const std::string &lockfile_name)
 
bool DirIsWritable (const fs::path &directory)
 
bool CheckDiskSpace (const fs::path &dir, uint64_t additional_bytes=0)
 
void ReleaseDirectoryLocks ()
 Release all directory locks. More...
 
bool TryCreateDirectories (const fs::path &p)
 Ignores exceptions thrown by Boost's create_directories if the requested directory exists. More...
 
fs::path GetDefaultDataDir ()
 
const fs::path & GetBlocksDir ()
 
const fs::path & GetDataDir (bool fNetSpecific=true)
 
void ClearDatadirCache ()
 
fs::path GetConfigFile (const std::string &confPath)
 
void runCommand (const std::string &strCommand)
 
fs::path AbsPathForConfigVal (const fs::path &path, bool net_specific=true)
 Most paths passed as configuration arguments are treated as relative to the datadir if they are not absolute. More...
 
bool IsSwitchChar (char c)
 
bool HelpRequested (const ArgsManager &args)
 
void SetupHelpOptions (ArgsManager &args)
 Add help options to the args manager. 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...
 
int GetNumCores ()
 Return the number of cores available on the current system. More...
 
template<typename Callable >
void TraceThread (const char *name, Callable func)
 
std::string CopyrightHolders (const std::string &strPrefix)
 
int ScheduleBatchPriority ()
 On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive. More...
 
template<typename Tdst , typename Tsrc >
void util::insert (Tdst &dst, const Tsrc &src)
 Simplification of std insertion. More...
 
template<typename TsetT , typename Tsrc >
void util::insert (std::set< TsetT > &dst, const Tsrc &src)
 

Variables

const char *const BITCOIN_CONF_FILENAME
 
const std::function< std::string(const char *)> G_TRANSLATION_FUN
 Translate a message to the native language of the user. More...
 
ArgsManager gArgs
 

Enumeration Type Documentation

◆ OptionsCategory

enum OptionsCategory
strong
Enumerator
OPTIONS 
CONNECTION 
WALLET 
WALLET_DEBUG_TEST 
ZMQ 
DEBUG_TEST 
CHAINPARAMS 
NODE_RELAY 
BLOCK_CREATION 
RPC 
GUI 
COMMANDS 
REGISTER_COMMANDS 
HIDDEN 

Definition at line 114 of file system.h.

Function Documentation

◆ _()

std::string _ ( const char *  psz)
inline

Translation function.

If no translation function is set, simply return the input.

Definition at line 52 of file system.h.

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

◆ AbsPathForConfigVal()

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

Most paths passed as configuration arguments are treated as relative to the datadir if they are not absolute.

Parameters
pathThe path to be conditionally prefixed with datadir.
net_specificForwarded to GetDataDir().
Returns
The normalized path.

Definition at line 1206 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

Definition at line 1063 of file system.cpp.

◆ CheckDiskSpace()

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

Definition at line 132 of file system.cpp.

Here is the caller graph for this function:

◆ ClearDatadirCache()

void ClearDatadirCache ( )

Definition at line 770 of file system.cpp.

◆ CopyrightHolders()

std::string CopyrightHolders ( const std::string &  strPrefix)

Definition at line 1189 of file system.cpp.

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

◆ DirIsWritable()

bool DirIsWritable ( const fs::path &  directory)

Definition at line 119 of file system.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 system.h.

Here is the caller graph for this function:

◆ FileCommit()

bool FileCommit ( FILE *  file)

Definition at line 995 of file system.cpp.

Here is the caller graph for this function:

◆ GetBlocksDir()

const fs::path& GetBlocksDir ( )

Definition at line 710 of file system.cpp.

Here is the caller graph for this function:

◆ GetConfigFile()

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

Definition at line 779 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 = true)

Definition at line 738 of file system.cpp.

Here is the caller graph for this function:

◆ GetDefaultDataDir()

fs::path GetDefaultDataDir ( )

Definition at line 679 of file system.cpp.

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 1184 of file system.cpp.

Here is the caller graph for this function:

◆ GetStartupTime()

int64_t GetStartupTime ( )

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

Definition at line 1201 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 645 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 649 of file system.cpp.

Here is the caller graph for this function:

◆ HelpRequested()

bool HelpRequested ( const ArgsManager args)
Returns
true if help has been requested via a command-line arg

Definition at line 630 of file system.cpp.

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

◆ IsSwitchChar()

bool IsSwitchChar ( char  c)
inline

Definition at line 105 of file system.h.

◆ LockDirectory()

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

Definition at line 83 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 672 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 1040 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 113 of file system.cpp.

◆ RenameOver()

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

Definition at line 965 of file system.cpp.

◆ runCommand()

void runCommand ( const std::string &  strCommand)

Definition at line 1123 of file system.cpp.

◆ ScheduleBatchPriority()

int ScheduleBatchPriority ( )

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_setschedule().

Definition at line 1211 of file system.cpp.

◆ SetupEnvironment()

void SetupEnvironment ( )

Definition at line 1135 of file system.cpp.

Here is the caller graph for this function:

◆ SetupHelpOptions()

void SetupHelpOptions ( ArgsManager args)

Add help options to the args manager.

Definition at line 635 of file system.cpp.

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

◆ SetupNetworking()

bool SetupNetworking ( )

Definition at line 1172 of file system.cpp.

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 332 of file system.h.

Here is the call graph for this function:

◆ TruncateFile()

bool TruncateFile ( FILE *  file,
unsigned int  length 
)

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

Here is the caller graph for this function:

◆ UnlockDirectory()

void UnlockDirectory ( const fs::path &  directory,
const std::string &  lockfile_name 
)

Definition at line 107 of file system.cpp.

Variable Documentation

◆ BITCOIN_CONF_FILENAME

const char* const BITCOIN_CONF_FILENAME

Definition at line 70 of file system.cpp.

◆ G_TRANSLATION_FUN

const std::function<std::string(const char*)> G_TRANSLATION_FUN

Translate a message to the native language of the user.

Translate a message to the native language of the user.

Definition at line 28 of file bitcoin-cli.cpp.

◆ gArgs

ArgsManager gArgs

Definition at line 72 of file system.cpp.