Dash Core  0.12.2.1
P2P Digital Currency
init.cpp File Reference
#include "init.h"
#include "addrman.h"
#include "amount.h"
#include "chain.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "compat/sanity.h"
#include "consensus/validation.h"
#include "httpserver.h"
#include "httprpc.h"
#include "key.h"
#include "validation.h"
#include "miner.h"
#include "netbase.h"
#include "net.h"
#include "netfulfilledman.h"
#include "net_processing.h"
#include "policy/policy.h"
#include "rpc/server.h"
#include "script/standard.h"
#include "script/sigcache.h"
#include "scheduler.h"
#include "txdb.h"
#include "txmempool.h"
#include "torcontrol.h"
#include "ui_interface.h"
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
#include "validationinterface.h"
#include "activemasternode.h"
#include "dsnotificationinterface.h"
#include "flat-database.h"
#include "governance.h"
#include "instantx.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "masternodeconfig.h"
#include "messagesigner.h"
#include "privatesend-client.h"
#include "privatesend-server.h"
#include "spork.h"
#include <stdint.h>
#include <stdio.h>
#include <memory>
#include <signal.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>

Go to the source code of this file.

Classes

class  CCoinsViewErrorCatcher
 
struct  CImportingNow
 

Macros

#define MIN_CORE_FILEDESCRIPTORS   150
 

Enumerations

enum  BindFlags { BF_NONE = 0, BF_EXPLICIT = (1U << 0), BF_REPORT_ERROR = (1U << 1), BF_WHITELIST = (1U << 2) }
 

Functions

void ThreadSendAlert (CConnman &connman)
 
void StartShutdown ()
 
bool ShutdownRequested ()
 
void Interrupt (boost::thread_group &threadGroup)
 
void PrepareShutdown ()
 
void Shutdown ()
 
void HandleSIGTERM (int)
 
void HandleSIGHUP (int)
 
static bool InitError (const std::string &str)
 
static bool InitWarning (const std::string &str)
 
static bool Bind (CConnman &connman, const CService &addr, unsigned int flags)
 
void OnRPCStopped ()
 
void OnRPCPreCommand (const CRPCCommand &cmd)
 
std::string HelpMessage (HelpMessageMode mode)
 
std::string LicenseInfo ()
 
static void BlockNotifyCallback (bool initialSync, const CBlockIndex *pBlockIndex)
 
void CleanupBlockRevFiles ()
 
void ThreadImport (std::vector< boost::filesystem::path > vImportFiles)
 
bool InitSanityCheck (void)
 
bool AppInitServers (boost::thread_group &threadGroup)
 
void InitParameterInteraction ()
 Parameter interaction: change current parameters depending on various rules. More...
 
void InitLogging ()
 Initialize the logging infrastructure. More...
 
bool AppInit2 (boost::thread_group &threadGroup, CScheduler &scheduler)
 

Variables

bool fFeeEstimatesInitialized = false
 
bool fRestartRequested = false
 
static const bool DEFAULT_PROXYRANDOMIZE = true
 
static const bool DEFAULT_REST_ENABLE = false
 
static const bool DEFAULT_DISABLE_SAFEMODE = false
 
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false
 
std::unique_ptr< CConnmang_connman
 
std::unique_ptr< PeerLogicValidationpeerLogic
 
static CDSNotificationInterfacepdsNotificationInterface = NULL
 
static const char * FEE_ESTIMATES_FILENAME ="fee_estimates.dat"
 
CClientUIInterface uiInterface
 
volatile bool fRequestShutdown = false
 
static CCoinsViewDBpcoinsdbview = NULL
 
static CCoinsViewErrorCatcherpcoinscatcher = NULL
 
static boost::scoped_ptr< ECCVerifyHandleglobalVerifyHandle
 

Macro Definition Documentation

◆ MIN_CORE_FILEDESCRIPTORS

#define MIN_CORE_FILEDESCRIPTORS   150

Definition at line 118 of file init.cpp.

Referenced by AppInit2().

Enumeration Type Documentation

◆ BindFlags

enum BindFlags

Used to pass flags to the Bind() function

Enumerator
BF_NONE 
BF_EXPLICIT 
BF_REPORT_ERROR 
BF_WHITELIST 

Definition at line 122 of file init.cpp.

Function Documentation

◆ AppInit2()

bool AppInit2 ( boost::thread_group &  threadGroup,
CScheduler scheduler 
)

Initialize Dash Core.

Precondition
Parameters should be parsed and config file should be read.

Definition at line 942 of file init.cpp.

Referenced by AppInit(), and BitcoinCore::initialize().

◆ AppInitServers()

bool AppInitServers ( boost::thread_group &  threadGroup)

Definition at line 800 of file init.cpp.

Referenced by AppInit2().

◆ Bind()

static bool Bind ( CConnman connman,
const CService addr,
unsigned int  flags 
)
static

Definition at line 357 of file init.cpp.

Referenced by AppInit2().

◆ BlockNotifyCallback()

static void BlockNotifyCallback ( bool  initialSync,
const CBlockIndex pBlockIndex 
)
static

Definition at line 652 of file init.cpp.

Referenced by AppInit2().

◆ CleanupBlockRevFiles()

void CleanupBlockRevFiles ( )

Definition at line 683 of file init.cpp.

Referenced by AppInit2().

◆ HandleSIGHUP()

void HandleSIGHUP ( int  )

Definition at line 340 of file init.cpp.

Referenced by AppInit2().

◆ HandleSIGTERM()

void HandleSIGTERM ( int  )

Signal handlers are very limited in what they are allowed to do, so:

Definition at line 335 of file init.cpp.

Referenced by AppInit2().

◆ HelpMessage()

std::string HelpMessage ( HelpMessageMode  mode)

Help for options shared between UI and daemon (for -help)

Definition at line 384 of file init.cpp.

Referenced by AppInit(), and HelpMessageDialog::HelpMessageDialog().

◆ InitError()

static bool InitError ( const std::string &  str)
static

Definition at line 345 of file init.cpp.

Referenced by AppInit2(), Bind(), and InitSanityCheck().

◆ InitLogging()

void InitLogging ( )

Initialize the logging infrastructure.

Definition at line 926 of file init.cpp.

Referenced by AppInit(), and BitcoinApplication::parameterSetup().

◆ InitParameterInteraction()

void InitParameterInteraction ( )

Parameter interaction: change current parameters depending on various rules.

Definition at line 818 of file init.cpp.

Referenced by AppInit(), and BitcoinApplication::parameterSetup().

◆ InitSanityCheck()

bool InitSanityCheck ( void  )

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

Definition at line 788 of file init.cpp.

Referenced by AppInit2().

◆ InitWarning()

static bool InitWarning ( const std::string &  str)
static

Definition at line 351 of file init.cpp.

Referenced by AppInit2().

◆ Interrupt()

void Interrupt ( boost::thread_group &  threadGroup)

Interrupt threads

Definition at line 197 of file init.cpp.

Referenced by AppInit(), BitcoinCore::shutdown(), and WaitForShutdown().

◆ LicenseInfo()

std::string LicenseInfo ( )

Returns licensing information (for -version)

Definition at line 637 of file init.cpp.

Referenced by AppInit(), and HelpMessageDialog::HelpMessageDialog().

◆ OnRPCPreCommand()

void OnRPCPreCommand ( const CRPCCommand cmd)

Definition at line 375 of file init.cpp.

Referenced by AppInitServers().

◆ OnRPCStopped()

void OnRPCStopped ( )

Definition at line 369 of file init.cpp.

Referenced by AppInitServers().

◆ PrepareShutdown()

void PrepareShutdown ( )

Preparing steps before shutting down or restarting the wallet

Note: Shutdown() must be able to handle cases in which AppInit2() 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 210 of file init.cpp.

Referenced by BitcoinCore::restart(), and Shutdown().

◆ Shutdown()

void Shutdown ( )

Shutdown is split into 2 parts: Part 1: shut down everything but the main wallet instance (done in PrepareShutdown() ) Part 2: delete wallet instance

In case of a restart PrepareShutdown() was already called before, but this method here gets called implicitly when the parent object is deleted. In this case we have to skip the PrepareShutdown() part because it was already executed and just delete the wallet instance.

Definition at line 315 of file init.cpp.

Referenced by AppInit(), and BitcoinCore::shutdown().

◆ ShutdownRequested()

◆ StartShutdown()

void StartShutdown ( )

Definition at line 164 of file init.cpp.

Referenced by SplashScreen::closeEvent(), encryptwallet(), stop(), and ThreadImport().

◆ ThreadImport()

void ThreadImport ( std::vector< boost::filesystem::path >  vImportFiles)

Definition at line 719 of file init.cpp.

Referenced by AppInit2().

◆ ThreadSendAlert()

void ThreadSendAlert ( CConnman connman)

Definition at line 26 of file sendalert.cpp.

Referenced by AppInit2().

Variable Documentation

◆ DEFAULT_DISABLE_SAFEMODE

const bool DEFAULT_DISABLE_SAFEMODE = false
static

Definition at line 100 of file init.cpp.

Referenced by HelpMessage(), and OnRPCPreCommand().

◆ DEFAULT_PROXYRANDOMIZE

const bool DEFAULT_PROXYRANDOMIZE = true
static

Definition at line 98 of file init.cpp.

Referenced by AppInit2(), and HelpMessage().

◆ DEFAULT_REST_ENABLE

const bool DEFAULT_REST_ENABLE = false
static

Definition at line 99 of file init.cpp.

Referenced by AppInitServers(), and HelpMessage().

◆ DEFAULT_STOPAFTERBLOCKIMPORT

const bool DEFAULT_STOPAFTERBLOCKIMPORT = false
static

Definition at line 101 of file init.cpp.

Referenced by HelpMessage(), and ThreadImport().

◆ FEE_ESTIMATES_FILENAME

const char* FEE_ESTIMATES_FILENAME ="fee_estimates.dat"
static

Definition at line 129 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ fFeeEstimatesInitialized

bool fFeeEstimatesInitialized = false

Definition at line 96 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ fRequestShutdown

volatile bool fRequestShutdown = false

Definition at line 162 of file init.cpp.

Referenced by AppInit2(), HandleSIGTERM(), PrepareShutdown(), ShutdownRequested(), and StartShutdown().

◆ fRestartRequested

bool fRestartRequested = false

Definition at line 97 of file init.cpp.

Referenced by PrepareShutdown(), Shutdown(), and ShutdownRequested().

◆ g_connman

◆ globalVerifyHandle

boost::scoped_ptr<ECCVerifyHandle> globalVerifyHandle
static

Definition at line 195 of file init.cpp.

Referenced by AppInit2(), and Shutdown().

◆ pcoinscatcher

CCoinsViewErrorCatcher* pcoinscatcher = NULL
static

Definition at line 194 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ pcoinsdbview

CCoinsViewDB* pcoinsdbview = NULL
static

Definition at line 193 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ pdsNotificationInterface

CDSNotificationInterface* pdsNotificationInterface = NULL
static

Definition at line 110 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ peerLogic

std::unique_ptr<PeerLogicValidation> peerLogic

Definition at line 104 of file init.cpp.

Referenced by AppInit2(), and PrepareShutdown().

◆ uiInterface