Bitcoin
Classes | Namespaces | Macros | Functions | Variables
init.cpp File Reference
#include <init.h>
#include <addrman.h>
#include <amount.h>
#include <banman.h>
#include <blockfilter.h>
#include <chain.h>
#include <chainparams.h>
#include <compat/sanity.h>
#include <consensus/validation.h>
#include <fs.h>
#include <httpserver.h>
#include <httprpc.h>
#include <index/blockfilterindex.h>
#include <interfaces/chain.h>
#include <index/txindex.h>
#include <key.h>
#include <validation.h>
#include <miner.h>
#include <netbase.h>
#include <net.h>
#include <net_processing.h>
#include <policy/feerate.h>
#include <policy/fees.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <rpc/server.h>
#include <rpc/register.h>
#include <rpc/blockchain.h>
#include <rpc/util.h>
#include <script/standard.h>
#include <script/sigcache.h>
#include <scheduler.h>
#include <shutdown.h>
#include <util/threadnames.h>
#include <timedata.h>
#include <txdb.h>
#include <txmempool.h>
#include <torcontrol.h>
#include <ui_interface.h>
#include <util/system.h>
#include <util/moneystr.h>
#include <util/validation.h>
#include <validationinterface.h>
#include <walletinitinterface.h>
#include <stdint.h>
#include <stdio.h>
#include <attributes.h>
#include <cerrno>
#include <signal.h>
#include <sys/stat.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/thread.hpp>

Classes

class  CCoinsViewErrorCatcher
 
struct  CImportingNow
 

Namespaces

 anonymous_namespace{init.cpp}
 

Macros

#define MIN_CORE_FILEDESCRIPTORS   150
 

Functions

static fs::path GetPidFile ()
 
static NODISCARD bool CreatePidFile ()
 
void Interrupt ()
 
void Shutdown (InitInterfaces &interfaces)
 
static void HandleSIGTERM (int)
 
static void HandleSIGHUP (int)
 
static void registerSignalHandler (int signal, void(*handler)(int))
 
static void OnRPCStarted ()
 
static void OnRPCStopped ()
 
void SetupServerArgs ()
 
std::string LicenseInfo ()
 
static void BlockNotifyGenesisWait (bool, const CBlockIndex *pBlockIndex)
 
static void CleanupBlockRevFiles ()
 
static void ThreadImport (std::vector< fs::path > vImportFiles)
 
static bool InitSanityCheck ()
 
static bool AppInitServers ()
 
void InitParameterInteraction ()
 Parameter interaction: change current parameters depending on various rules. More...
 
static std::string ResolveErrMsg (const char *const optname, const std::string &strBind)
 
void InitLogging ()
 Initialize the logging infrastructure. More...
 
static void new_handler_terminate ()
 
bool AppInitBasicSetup ()
 
bool AppInitParameterInteraction ()
 
static bool LockDataDirectory (bool probeOnly)
 
bool AppInitSanityChecks ()
 
bool AppInitLockDataDirectory ()
 
bool AppInitMain (InitInterfaces &interfaces)
 

Variables

static bool fFeeEstimatesInitialized = false
 
static const bool DEFAULT_PROXYRANDOMIZE = true
 
static const bool DEFAULT_REST_ENABLE = false
 
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false
 
static constexpr int DUMP_BANS_INTERVAL = 60 * 15
 
std::unique_ptr< CConnmang_connman
 
std::unique_ptr< PeerLogicValidationpeerLogic
 
std::unique_ptr< BanMang_banman
 
static const char * FEE_ESTIMATES_FILENAME ="fee_estimates.dat"
 
static const char * BITCOIN_PID_FILENAME = "bitcoind.pid"
 
static std::unique_ptr< CCoinsViewErrorCatcherpcoinscatcher
 
static std::unique_ptr< ECCVerifyHandleglobalVerifyHandle
 
static boost::thread_group threadGroup
 
static CScheduler scheduler
 
static boost::signals2::connection rpc_notify_block_change_connection
 
static bool fHaveGenesis = false
 
static Mutex g_genesis_wait_mutex
 
static std::condition_variable g_genesis_wait_cv
 
int anonymous_namespace{init.cpp}::nMaxConnections
 
int anonymous_namespace{init.cpp}::nUserMaxConnections
 
int anonymous_namespace{init.cpp}::nFD
 
ServiceFlags anonymous_namespace{init.cpp}::nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED)
 
int64_t anonymous_namespace{init.cpp}::peer_connect_timeout
 
std::vector< BlockFilterTypeanonymous_namespace{init.cpp}::g_enabled_filter_types
 

Macro Definition Documentation

◆ MIN_CORE_FILEDESCRIPTORS

#define MIN_CORE_FILEDESCRIPTORS   150

Function Documentation

◆ AppInitBasicSetup()

bool AppInitBasicSetup ( )

Initialize bitcoin core: 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.

◆ AppInitLockDataDirectory()

bool AppInitLockDataDirectory ( )

Lock bitcoin core 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.

◆ AppInitMain()

bool AppInitMain ( InitInterfaces interfaces)

Bitcoin core main initialization.

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

◆ AppInitParameterInteraction()

bool AppInitParameterInteraction ( )

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.

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

◆ AppInitServers()

static bool AppInitServers ( )
static

◆ BlockNotifyGenesisWait()

static void BlockNotifyGenesisWait ( bool  ,
const CBlockIndex pBlockIndex 
)
static

◆ CleanupBlockRevFiles()

static void CleanupBlockRevFiles ( )
static

◆ CreatePidFile()

static NODISCARD bool CreatePidFile ( )
static

◆ GetPidFile()

static fs::path GetPidFile ( )
static

◆ HandleSIGHUP()

static void HandleSIGHUP ( int  )
static

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

◆ InitLogging()

void InitLogging ( )

Initialize the logging infrastructure.

Initialize global loggers.

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

◆ InitParameterInteraction()

void InitParameterInteraction ( )

Parameter interaction: change current parameters depending on various rules.

◆ InitSanityCheck()

static bool InitSanityCheck ( )
static

Sanity checks Ensure that Bitcoin is running in a usable environment with all necessary library support.

◆ Interrupt()

void Interrupt ( )

Interrupt threads

◆ LicenseInfo()

std::string LicenseInfo ( )

Returns licensing information (for -version)

◆ LockDataDirectory()

static bool LockDataDirectory ( bool  probeOnly)
static

◆ new_handler_terminate()

static void new_handler_terminate ( )
static

◆ OnRPCStarted()

static void OnRPCStarted ( )
static

◆ OnRPCStopped()

static void OnRPCStopped ( )
static

◆ registerSignalHandler()

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

◆ ResolveErrMsg()

static std::string ResolveErrMsg ( const char *const  optname,
const std::string &  strBind 
)
static

◆ SetupServerArgs()

void SetupServerArgs ( )

Setup the arguments for gArgs

◆ Shutdown()

void Shutdown ( InitInterfaces interfaces)

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.

◆ ThreadImport()

static void ThreadImport ( std::vector< fs::path >  vImportFiles)
static

Variable Documentation

◆ BITCOIN_PID_FILENAME

const char* BITCOIN_PID_FILENAME = "bitcoind.pid"
static

The PID file facilities.

◆ DEFAULT_PROXYRANDOMIZE

const bool DEFAULT_PROXYRANDOMIZE = true
static

◆ DEFAULT_REST_ENABLE

const bool DEFAULT_REST_ENABLE = false
static

◆ DEFAULT_STOPAFTERBLOCKIMPORT

const bool DEFAULT_STOPAFTERBLOCKIMPORT = false
static

◆ DUMP_BANS_INTERVAL

constexpr int DUMP_BANS_INTERVAL = 60 * 15
static

◆ FEE_ESTIMATES_FILENAME

const char* FEE_ESTIMATES_FILENAME ="fee_estimates.dat"
static

◆ fFeeEstimatesInitialized

bool fFeeEstimatesInitialized = false
static

◆ fHaveGenesis

bool fHaveGenesis = false
static

◆ g_banman

std::unique_ptr<BanMan> g_banman

◆ g_connman

std::unique_ptr<CConnman> g_connman

◆ g_genesis_wait_cv

std::condition_variable g_genesis_wait_cv
static

◆ g_genesis_wait_mutex

Mutex g_genesis_wait_mutex
static

◆ globalVerifyHandle

std::unique_ptr<ECCVerifyHandle> globalVerifyHandle
static

◆ pcoinscatcher

std::unique_ptr<CCoinsViewErrorCatcher> pcoinscatcher
static

◆ peerLogic

std::unique_ptr<PeerLogicValidation> peerLogic

◆ rpc_notify_block_change_connection

boost::signals2::connection rpc_notify_block_change_connection
static

◆ scheduler

CScheduler scheduler
static

◆ threadGroup

boost::thread_group threadGroup
static