diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-04-16 14:47:18 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-09-08 12:04:35 -0400 |
commit | cd16f48028f54327d4afba9c1f91f25d0b072aa5 (patch) | |
tree | 898569d833ac7d3f40e6cf3129262321894ac6db /src/init.cpp | |
parent | d93b14dc5ddfb937b0cc18be425b9d048cefb66b (diff) |
net: Create CConnman to encapsulate p2p connections
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp index 27843fa882..6aaa7bfc5d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -42,6 +42,7 @@ #endif #include <stdint.h> #include <stdio.h> +#include <memory> #ifndef WIN32 #include <signal.h> @@ -70,6 +71,7 @@ static const bool DEFAULT_REST_ENABLE = false; static const bool DEFAULT_DISABLE_SAFEMODE = false; static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; +std::unique_ptr<CConnman> g_connman; #if ENABLE_ZMQ static CZMQNotificationInterface* pzmqNotificationInterface = NULL; @@ -197,7 +199,9 @@ void Shutdown() if (pwalletMain) pwalletMain->Flush(false); #endif - StopNode(); + StopNode(*g_connman); + g_connman.reset(); + StopTorControl(); UnregisterNodeSignals(GetNodeSignals()); @@ -1101,6 +1105,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif // ENABLE_WALLET // ********************************************************* Step 6: network initialization + assert(!g_connman); + g_connman = std::unique_ptr<CConnman>(new CConnman()); + CConnman& connman = *g_connman; + RegisterNodeSignals(GetNodeSignals()); // sanitize comments per BIP-0014, format user agent and check total size @@ -1497,7 +1505,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) StartTorControl(threadGroup, scheduler); - StartNode(threadGroup, scheduler); + std::string strNodeError; + if(!StartNode(connman, threadGroup, scheduler, strNodeError)) + return InitError(strNodeError); // ********************************************************* Step 12: finished |