Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | static void registerSignalHandler(int signal, void (*handler)(int)) { | ||||
struct sigaction sa; | struct sigaction sa; | ||||
sa.sa_handler = handler; | sa.sa_handler = handler; | ||||
sigemptyset(&sa.sa_mask); | sigemptyset(&sa.sa_mask); | ||||
sa.sa_flags = 0; | sa.sa_flags = 0; | ||||
sigaction(signal, &sa, NULL); | sigaction(signal, &sa, NULL); | ||||
} | } | ||||
#endif | #endif | ||||
static boost::signals2::connection rpc_notify_block_change_connection; | |||||
static void OnRPCStarted() { | static void OnRPCStarted() { | ||||
rpc_notify_block_change_connection = | |||||
uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange); | uiInterface.NotifyBlockTip_connect(&RPCNotifyBlockChange); | ||||
} | } | ||||
static void OnRPCStopped() { | static void OnRPCStopped() { | ||||
uiInterface.NotifyBlockTip_disconnect(&RPCNotifyBlockChange); | rpc_notify_block_change_connection.disconnect(); | ||||
RPCNotifyBlockChange(false, nullptr); | RPCNotifyBlockChange(false, nullptr); | ||||
g_best_block_cv.notify_all(); | g_best_block_cv.notify_all(); | ||||
LogPrint(BCLog::RPC, "RPC stopped.\n"); | LogPrint(BCLog::RPC, "RPC stopped.\n"); | ||||
} | } | ||||
void SetupServerArgs() { | void SetupServerArgs() { | ||||
const auto defaultBaseParams = | const auto defaultBaseParams = | ||||
CreateBaseChainParams(CBaseChainParams::MAIN); | CreateBaseChainParams(CBaseChainParams::MAIN); | ||||
▲ Show 20 Lines • Show All 2,308 Lines • ▼ Show 20 Lines | if (!CheckDiskSpace(GetBlocksDir())) { | ||||
InitError(strprintf(_("Error: Disk space is low for %s").translated, | InitError(strprintf(_("Error: Disk space is low for %s").translated, | ||||
GetBlocksDir())); | GetBlocksDir())); | ||||
return false; | return false; | ||||
} | } | ||||
// Either install a handler to notify us when genesis activates, or set | // Either install a handler to notify us when genesis activates, or set | ||||
// fHaveGenesis directly. | // fHaveGenesis directly. | ||||
// No locking, as this happens before any background thread is started. | // No locking, as this happens before any background thread is started. | ||||
boost::signals2::connection block_notify_genesis_wait_connection; | |||||
if (::ChainActive().Tip() == nullptr) { | if (::ChainActive().Tip() == nullptr) { | ||||
block_notify_genesis_wait_connection = | |||||
uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | ||||
} else { | } else { | ||||
fHaveGenesis = true; | fHaveGenesis = true; | ||||
} | } | ||||
#if defined(HAVE_SYSTEM) | #if defined(HAVE_SYSTEM) | ||||
if (gArgs.IsArgSet("-blocknotify")) { | if (gArgs.IsArgSet("-blocknotify")) { | ||||
uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | ||||
} | } | ||||
Show All 11 Lines | #endif | ||||
{ | { | ||||
WAIT_LOCK(g_genesis_wait_mutex, lock); | WAIT_LOCK(g_genesis_wait_mutex, lock); | ||||
// We previously could hang here if StartShutdown() is called prior to | // We previously could hang here if StartShutdown() is called prior to | ||||
// ThreadImport getting started, so instead we just wait on a timer to | // ThreadImport getting started, so instead we just wait on a timer to | ||||
// check ShutdownRequested() regularly. | // check ShutdownRequested() regularly. | ||||
while (!fHaveGenesis && !ShutdownRequested()) { | while (!fHaveGenesis && !ShutdownRequested()) { | ||||
g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500)); | g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500)); | ||||
} | } | ||||
uiInterface.NotifyBlockTip_disconnect(BlockNotifyGenesisWait); | block_notify_genesis_wait_connection.disconnect(); | ||||
} | } | ||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
return false; | return false; | ||||
} | } | ||||
// Step 12: start node | // Step 12: start node | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |