multiprocess: Add bitcoin-node process spawning support

Add bitcoin-node startup code to let it spawn and be spawned by other
processes
This commit is contained in:
Russell Yanofsky
2017-12-05 15:57:12 -05:00
parent 10afdf0280
commit ddf7ecc8df
7 changed files with 105 additions and 6 deletions

View File

@@ -12,6 +12,7 @@
#include <compat.h>
#include <init.h>
#include <interfaces/chain.h>
#include <interfaces/init.h>
#include <node/context.h>
#include <node/ui_interface.h>
#include <noui.h>
@@ -104,10 +105,8 @@ int fork_daemon(bool nochdir, bool noclose, TokenPipeEnd& endpoint)
#endif
static bool AppInit(int argc, char* argv[])
static bool AppInit(NodeContext& node, int argc, char* argv[])
{
NodeContext node;
bool fRet = false;
util::ThreadSetInternalName("init");
@@ -254,10 +253,18 @@ int main(int argc, char* argv[])
util::WinCmdLineArgs winArgs;
std::tie(argc, argv) = winArgs.get();
#endif
NodeContext node;
int exit_status;
std::unique_ptr<interfaces::Init> init = interfaces::MakeNodeInit(node, argc, argv, exit_status);
if (!init) {
return exit_status;
}
SetupEnvironment();
// Connect bitcoind signal handlers
noui_connect();
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
return (AppInit(node, argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
}