mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-13 07:23:21 +02:00
net: Create CConnman to encapsulate p2p connections
This commit is contained in:
14
src/init.cpp
14
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user