Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoind.cpp
Show All 9 Lines | |||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <clientversion.h> | #include <clientversion.h> | ||||
#include <compat.h> | #include <compat.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <httprpc.h> | #include <httprpc.h> | ||||
#include <httpserver.h> | #include <httpserver.h> | ||||
#include <init.h> | #include <init.h> | ||||
#include <interfaces/chain.h> | |||||
#include <noui.h> | #include <noui.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <walletinitinterface.h> | #include <walletinitinterface.h> | ||||
#include <cstdio> | #include <cstdio> | ||||
Show All 35 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; | |||||
interfaces.chain = interfaces::MakeChain(); | |||||
bool fRet = false; | bool fRet = false; | ||||
// | // | ||||
// Parameters | // Parameters | ||||
// | // | ||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's | // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's | ||||
// main() | // main() | ||||
SetupServerArgs(); | SetupServerArgs(); | ||||
▲ Show 20 Lines • Show All 112 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 = AppInitMain(config, rpcServer, httpRPCRequestProcessor); | fRet = | ||||
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(); | Shutdown(interfaces); | ||||
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); | ||||
} | } |