Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,108 Lines • ▼ Show 20 Lines | bool InitSanityCheck(void) { | ||||
if (!Random_SanityCheck()) { | if (!Random_SanityCheck()) { | ||||
InitError("OS cryptographic RNG sanity check failure. Aborting."); | InitError("OS cryptographic RNG sanity check failure. Aborting."); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static bool AppInitServers(Config &config, boost::thread_group &threadGroup) { | static bool AppInitServers(Config &config, | ||||
HTTPRPCRequestProcessor &httpRPCRequestProcessor, | |||||
boost::thread_group &threadGroup) { | |||||
RPCServerSignals::OnStarted(&OnRPCStarted); | RPCServerSignals::OnStarted(&OnRPCStarted); | ||||
RPCServerSignals::OnStopped(&OnRPCStopped); | RPCServerSignals::OnStopped(&OnRPCStopped); | ||||
RPCServerSignals::OnPreCommand(&OnRPCPreCommand); | RPCServerSignals::OnPreCommand(&OnRPCPreCommand); | ||||
if (!InitHTTPServer(config)) { | if (!InitHTTPServer(config)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!StartRPC()) { | if (!StartRPC()) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!StartHTTPRPC(config)) { | if (!StartHTTPRPC(config, httpRPCRequestProcessor)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST()) { | if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST()) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!StartHTTPServer()) { | if (!StartHTTPServer()) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 586 Lines • ▼ Show 20 Lines | if (!InitSanityCheck()) { | ||||
_("Initialization sanity check failed. %s is shutting down."), | _("Initialization sanity check failed. %s is shutting down."), | ||||
_(PACKAGE_NAME))); | _(PACKAGE_NAME))); | ||||
} | } | ||||
// Probe the data directory lock to give an early error message, if possible | // Probe the data directory lock to give an early error message, if possible | ||||
return LockDataDirectory(true); | return LockDataDirectory(true); | ||||
} | } | ||||
bool AppInitMain(Config &config, boost::thread_group &threadGroup, | bool AppInitMain(Config &config, | ||||
CScheduler &scheduler) { | HTTPRPCRequestProcessor &httpRPCRequestProcessor, | ||||
boost::thread_group &threadGroup, CScheduler &scheduler) { | |||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
// Step 4a: application initialization | // Step 4a: application initialization | ||||
// After daemonization get the data directory lock again and hold on to it | // After daemonization get the data directory lock again and hold on to it | ||||
// until exit. This creates a slight window for a race condition to happen, | // until exit. This creates a slight window for a race condition to happen, | ||||
// however this condition is harmless: it will at most make us exit without | // however this condition is harmless: it will at most make us exit without | ||||
// printing a message to console. | // printing a message to console. | ||||
if (!LockDataDirectory(false)) { | if (!LockDataDirectory(false)) { | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | #endif | ||||
/** | /** | ||||
* Start the RPC server. It will be started in "warmup" mode and not | * 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 | * 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 | * be ready later). Warmup mode will be completed when initialisation is | ||||
* finished. | * finished. | ||||
*/ | */ | ||||
if (gArgs.GetBoolArg("-server", false)) { | if (gArgs.GetBoolArg("-server", false)) { | ||||
uiInterface.InitMessage.connect(SetRPCWarmupStatus); | uiInterface.InitMessage.connect(SetRPCWarmupStatus); | ||||
if (!AppInitServers(config, threadGroup)) { | if (!AppInitServers(config, httpRPCRequestProcessor, threadGroup)) { | ||||
return InitError( | return InitError( | ||||
_("Unable to start HTTP server. See debug log for details.")); | _("Unable to start HTTP server. See debug log for details.")); | ||||
} | } | ||||
} | } | ||||
// Step 5: verify wallet database integrity | // Step 5: verify wallet database integrity | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
if (!CWallet::Verify(chainparams)) { | if (!CWallet::Verify(chainparams)) { | ||||
▲ Show 20 Lines • Show All 500 Lines • Show Last 20 Lines |