Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoind.cpp
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
static bool AppInit(int argc, char *argv[]) { | static bool AppInit(int argc, char *argv[]) { | ||||
// FIXME: Ideally, we'd like to build the config here, but that's currently | // FIXME: Ideally, we'd like to build the config here, but that's currently | ||||
// not possible as the whole application has too many global state. However, | // not possible as the whole application has too many global state. However, | ||||
// this is a first step. | // this is a first step. | ||||
auto &config = const_cast<Config &>(GetConfig()); | auto &config = const_cast<Config &>(GetConfig()); | ||||
RPCServer rpcServer; | RPCServer rpcServer; | ||||
HTTPRPCRequestProcessor httpRPCRequestProcessor(config, rpcServer); | HTTPRPCRequestProcessor httpRPCRequestProcessor(config, rpcServer); | ||||
InitInterfaces interfaces; | NodeContext node; | ||||
interfaces.chain = interfaces::MakeChain(); | node.chain = interfaces::MakeChain(); | ||||
bool fRet = false; | bool fRet = false; | ||||
util::ThreadSetInternalName("init"); | util::ThreadSetInternalName("init"); | ||||
// | // | ||||
// Parameters | // Parameters | ||||
// | // | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
#endif // HAVE_DECL_DAEMON | #endif // HAVE_DECL_DAEMON | ||||
} | } | ||||
// Lock data directory after daemonization | // Lock data directory after daemonization | ||||
if (!AppInitLockDataDirectory()) { | if (!AppInitLockDataDirectory()) { | ||||
// If locking the data directory failed, exit immediately | // If locking the data directory failed, exit immediately | ||||
return false; | return false; | ||||
} | } | ||||
fRet = | fRet = AppInitMain(config, rpcServer, httpRPCRequestProcessor, node); | ||||
AppInitMain(config, rpcServer, httpRPCRequestProcessor, interfaces); | |||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
PrintExceptionContinue(&e, "AppInit()"); | PrintExceptionContinue(&e, "AppInit()"); | ||||
} catch (...) { | } catch (...) { | ||||
PrintExceptionContinue(nullptr, "AppInit()"); | PrintExceptionContinue(nullptr, "AppInit()"); | ||||
} | } | ||||
if (!fRet) { | if (!fRet) { | ||||
Interrupt(); | Interrupt(); | ||||
} else { | } else { | ||||
WaitForShutdown(); | WaitForShutdown(); | ||||
} | } | ||||
Shutdown(interfaces); | Shutdown(node); | ||||
return fRet; | return fRet; | ||||
} | } | ||||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
util::WinCmdLineArgs winArgs; | util::WinCmdLineArgs winArgs; | ||||
std::tie(argc, argv) = winArgs.get(); | std::tie(argc, argv) = winArgs.get(); | ||||
#endif | #endif | ||||
SetupEnvironment(); | SetupEnvironment(); | ||||
// Connect bitcoind signal handlers | // Connect bitcoind signal handlers | ||||
noui_connect(); | noui_connect(); | ||||
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE); | return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE); | ||||
} | } |