Bitcoin ABC  0.29.2
P2P Digital Currency
Macros | Functions | Variables
init.cpp File Reference
#include <init.h>
#include <kernel/mempool_persist.h>
#include <kernel/validation_cache_sizes.h>
#include <addrman.h>
#include <avalanche/avalanche.h>
#include <avalanche/processor.h>
#include <avalanche/proof.h>
#include <avalanche/validation.h>
#include <avalanche/voterecord.h>
#include <banman.h>
#include <blockfilter.h>
#include <chain.h>
#include <chainparams.h>
#include <compat/sanity.h>
#include <config.h>
#include <consensus/amount.h>
#include <currencyunit.h>
#include <flatfile.h>
#include <fs.h>
#include <hash.h>
#include <httprpc.h>
#include <httpserver.h>
#include <index/blockfilterindex.h>
#include <index/coinstatsindex.h>
#include <index/txindex.h>
#include <init/common.h>
#include <interfaces/chain.h>
#include <interfaces/node.h>
#include <mapport.h>
#include <mempool_args.h>
#include <net.h>
#include <net_permissions.h>
#include <net_processing.h>
#include <netbase.h>
#include <node/blockstorage.h>
#include <node/caches.h>
#include <node/chainstate.h>
#include <node/chainstatemanager_args.h>
#include <node/context.h>
#include <node/mempool_persist_args.h>
#include <node/miner.h>
#include <node/ui_interface.h>
#include <node/validation_cache_args.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <rpc/blockchain.h>
#include <rpc/register.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <scheduler.h>
#include <script/scriptcache.h>
#include <script/sigcache.h>
#include <script/standard.h>
#include <shutdown.h>
#include <sync.h>
#include <timedata.h>
#include <torcontrol.h>
#include <txdb.h>
#include <txmempool.h>
#include <txorphanage.h>
#include <util/asmap.h>
#include <util/check.h>
#include <util/moneystr.h>
#include <util/string.h>
#include <util/thread.h>
#include <util/threadnames.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
#include <walletinitinterface.h>
#include <boost/signals2/signal.hpp>
#include <cerrno>
#include <csignal>
#include <sys/stat.h>
#include <algorithm>
#include <condition_variable>
#include <cstdint>
#include <cstdio>
#include <fstream>
#include <functional>
#include <set>
#include <string>
#include <thread>
#include <vector>

Go to the source code of this file.

Macros

#define MIN_CORE_FILEDESCRIPTORS   150
 

Functions

static fs::path GetPidFile (const ArgsManager &args)
 
static bool CreatePidFile (const ArgsManager &args)
 
void Interrupt (NodeContext &node)
 Interrupt threads. More...
 
void Shutdown (NodeContext &node)
 
static void HandleSIGTERM (int)
 Signal handlers are very limited in what they are allowed to do. More...
 
static void HandleSIGHUP (int)
 
static void registerSignalHandler (int signal, void(*handler)(int))
 
static void OnRPCStarted ()
 
static void OnRPCStopped ()
 
void SetupServerArgs (NodeContext &node)
 Register all arguments with the ArgsManager. More...
 
std::string LicenseInfo ()
 Returns licensing information (for -version) More...
 
static void BlockNotifyGenesisWait (const CBlockIndex *pBlockIndex)
 
static bool AppInitServers (Config &config, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node)
 
void InitParameterInteraction (ArgsManager &args)
 Parameter interaction: change current parameters depending on various rules. More...
 
void InitLogging (const ArgsManager &args)
 Initialize global loggers. More...
 
static void new_handler_terminate ()
 
bool AppInitBasicSetup (const ArgsManager &args)
 Initialize bitcoin: Basic context setup. More...
 
bool AppInitParameterInteraction (Config &config, const ArgsManager &args)
 Initialization: parameter interaction. More...
 
static bool LockDataDirectory (bool probeOnly)
 
bool AppInitSanityChecks ()
 Initialization sanity checks: ecc init, sanity checks, dir lock. More...
 
bool AppInitLockDataDirectory ()
 Lock bitcoin data directory. More...
 
bool AppInitInterfaces (NodeContext &node)
 Initialize node and wallet interface pointers. More...
 
bool AppInitMain (Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
 Bitcoin main initialization. More...
 

Variables

static const bool DEFAULT_PROXYRANDOMIZE = true
 
static const bool DEFAULT_REST_ENABLE = false
 
static constexpr bool DEFAULT_CHRONIK = false
 
static const char * DEFAULT_ASMAP_FILENAME = "ip_asn.map"
 
static const char * BITCOIN_PID_FILENAME = "bitcoind.pid"
 The PID file facilities. More...
 
static boost::signals2::connection rpc_notify_block_change_connection
 
static bool fHaveGenesis = false
 
static GlobalMutex g_genesis_wait_mutex
 
static std::condition_variable g_genesis_wait_cv
 

Macro Definition Documentation

◆ MIN_CORE_FILEDESCRIPTORS

#define MIN_CORE_FILEDESCRIPTORS   150

Definition at line 139 of file init.cpp.

Function Documentation

◆ AppInitBasicSetup()

bool AppInitBasicSetup ( const ArgsManager args)

Initialize bitcoin: Basic context setup.

Note
This can be done before daemonization. Do not call Shutdown() if this function fails.
Precondition
Parameters should be parsed and config file should be read.

Definition at line 1669 of file init.cpp.

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

◆ AppInitInterfaces()

bool AppInitInterfaces ( node::NodeContext node)

Initialize node and wallet interface pointers.

Has no prerequisites or side effects besides allocating memory.

Definition at line 2061 of file init.cpp.

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

◆ AppInitLockDataDirectory()

bool AppInitLockDataDirectory ( )

Lock bitcoin data directory.

Note
This should only be done after daemonization. Do not call Shutdown() if this function fails.
Precondition
Parameters should be parsed and config file should be read, AppInitSanityChecks should have been called.

Definition at line 2049 of file init.cpp.

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

◆ AppInitMain()

bool AppInitMain ( Config config,
RPCServer rpcServer,
HTTPRPCRequestProcessor httpRPCRequestProcessor,
node::NodeContext node,
interfaces::BlockAndHeaderTipInfo tip_info = nullptr 
)

Bitcoin main initialization.

Note
This should only be done after daemonization.
Precondition
Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.

Register RPC commands regardless of -server setting so they will be available in the GUI RPC console even if external calls are disabled.

Start the RPC server. It will be started in "warmup" mode and not process calls yet (but it will verify that the server is there and will be ready later). Warmup mode will be completed when initialisation is finished.

Definition at line 2071 of file init.cpp.

Here is the caller graph for this function:

◆ AppInitParameterInteraction()

bool AppInitParameterInteraction ( Config config,
const ArgsManager args 
)

Initialization: parameter interaction.

Note
This can be done before daemonization. Do not call Shutdown() if this function fails.
Precondition
Parameters should be parsed and config file should be read, AppInitBasicSetup should have been called.

Definition at line 1716 of file init.cpp.

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

◆ AppInitSanityChecks()

bool AppInitSanityChecks ( )

Initialization sanity checks: ecc init, sanity checks, dir lock.

Note
This can be done before daemonization. Do not call Shutdown() if this function fails.
Precondition
Parameters should be parsed and config file should be read, AppInitParameterInteraction should have been called.

Definition at line 2031 of file init.cpp.

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

◆ AppInitServers()

static bool AppInitServers ( Config config,
HTTPRPCRequestProcessor httpRPCRequestProcessor,
NodeContext node 
)
static

Definition at line 1483 of file init.cpp.

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

◆ BlockNotifyGenesisWait()

static void BlockNotifyGenesisWait ( const CBlockIndex pBlockIndex)
static

Definition at line 1462 of file init.cpp.

Here is the caller graph for this function:

◆ CreatePidFile()

static bool CreatePidFile ( const ArgsManager args)
static

Definition at line 153 of file init.cpp.

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

◆ GetPidFile()

static fs::path GetPidFile ( const ArgsManager args)
static

Definition at line 149 of file init.cpp.

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

◆ HandleSIGHUP()

static void HandleSIGHUP ( int  )
static

Definition at line 381 of file init.cpp.

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

◆ HandleSIGTERM()

static void HandleSIGTERM ( int  )
static

Signal handlers are very limited in what they are allowed to do.

The execution context the handler is invoked in is not guaranteed, so we restrict handler operations to just touching variables:

Definition at line 377 of file init.cpp.

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

◆ InitLogging()

void InitLogging ( const ArgsManager args)

Initialize global loggers.

Initialize the logging infrastructure.

Note that this is called very early in the process lifetime, so you should be careful about what global state you rely on here.

Definition at line 1642 of file init.cpp.

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

◆ InitParameterInteraction()

void InitParameterInteraction ( ArgsManager args)

Parameter interaction: change current parameters depending on various rules.

Definition at line 1508 of file init.cpp.

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

◆ Interrupt()

void Interrupt ( NodeContext node)

Interrupt threads.

Definition at line 193 of file init.cpp.

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

◆ LicenseInfo()

std::string LicenseInfo ( )

Returns licensing information (for -version)

Definition at line 1427 of file init.cpp.

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

◆ LockDataDirectory()

static bool LockDataDirectory ( bool  probeOnly)
static

Definition at line 2015 of file init.cpp.

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

◆ new_handler_terminate()

static void new_handler_terminate ( )
static

Definition at line 1658 of file init.cpp.

Here is the caller graph for this function:

◆ OnRPCStarted()

static void OnRPCStarted ( )
static

Definition at line 403 of file init.cpp.

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

◆ OnRPCStopped()

static void OnRPCStopped ( )
static

Definition at line 408 of file init.cpp.

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

◆ registerSignalHandler()

static void registerSignalHandler ( int  signal,
void(*)(int)  handler 
)
static

Definition at line 393 of file init.cpp.

Here is the caller graph for this function:

◆ SetupServerArgs()

void SetupServerArgs ( NodeContext node)

Register all arguments with the ArgsManager.

Definition at line 415 of file init.cpp.

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

◆ Shutdown()

void Shutdown ( NodeContext node)

Note: Shutdown() must be able to handle cases in which initialization failed part of the way, for example if the data directory was found to be locked. Be sure that anything that writes files or flushes caches only does this if the respective module was initialized.

Definition at line 217 of file init.cpp.

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

Variable Documentation

◆ BITCOIN_PID_FILENAME

const char* BITCOIN_PID_FILENAME = "bitcoind.pid"
static

The PID file facilities.

Definition at line 147 of file init.cpp.

◆ DEFAULT_ASMAP_FILENAME

const char* DEFAULT_ASMAP_FILENAME = "ip_asn.map"
static

Definition at line 142 of file init.cpp.

◆ DEFAULT_CHRONIK

constexpr bool DEFAULT_CHRONIK = false
staticconstexpr

Definition at line 132 of file init.cpp.

◆ DEFAULT_PROXYRANDOMIZE

const bool DEFAULT_PROXYRANDOMIZE = true
static

Definition at line 130 of file init.cpp.

◆ DEFAULT_REST_ENABLE

const bool DEFAULT_REST_ENABLE = false
static

Definition at line 131 of file init.cpp.

◆ fHaveGenesis

bool fHaveGenesis = false
static

Definition at line 1458 of file init.cpp.

◆ g_genesis_wait_cv

std::condition_variable g_genesis_wait_cv
static

Definition at line 1460 of file init.cpp.

◆ g_genesis_wait_mutex

GlobalMutex g_genesis_wait_mutex
static

Definition at line 1459 of file init.cpp.

◆ rpc_notify_block_change_connection

boost::signals2::connection rpc_notify_block_change_connection
static

Definition at line 402 of file init.cpp.