@@ -85,9 +85,6 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
8585// Dump addresses to banlist.dat every 15 minutes (900s)
8686static constexpr int DUMP_BANS_INTERVAL = 60 * 15 ;
8787
88- std::unique_ptr<CConnman> g_connman;
89- std::unique_ptr<PeerLogicValidation> peerLogic;
90- std::unique_ptr<BanMan> g_banman;
9188
9289#ifdef WIN32
9390// Win32 LevelDB doesn't use filedescriptors, and the ones used for
@@ -163,8 +160,8 @@ void Interrupt(NodeContext& node)
163160 InterruptREST ();
164161 InterruptTorControl ();
165162 InterruptMapPort ();
166- if (g_connman )
167- g_connman ->Interrupt ();
163+ if (node. connman )
164+ node. connman ->Interrupt ();
168165 if (g_txindex) {
169166 g_txindex->Interrupt ();
170167 }
@@ -197,8 +194,8 @@ void Shutdown(NodeContext& node)
197194
198195 // Because these depend on each-other, we make sure that neither can be
199196 // using the other before destroying them.
200- if (peerLogic ) UnregisterValidationInterface (peerLogic .get ());
201- if (g_connman) g_connman ->Stop ();
197+ if (node. peer_logic ) UnregisterValidationInterface (node. peer_logic .get ());
198+ if (node. connman ) node. connman ->Stop ();
202199 if (g_txindex) g_txindex->Stop ();
203200 ForEachBlockFilterIndex ([](BlockFilterIndex& index) { index.Stop (); });
204201
@@ -211,9 +208,9 @@ void Shutdown(NodeContext& node)
211208
212209 // After the threads that potentially access these pointers have been stopped,
213210 // destruct and reset all to nullptr.
214- peerLogic .reset ();
215- g_connman .reset ();
216- g_banman .reset ();
211+ node. peer_logic .reset ();
212+ node. connman .reset ();
213+ node. banman .reset ();
217214 g_txindex.reset ();
218215 DestroyAllBlockFilterIndexes ();
219216
@@ -1315,13 +1312,13 @@ bool AppInitMain(NodeContext& node)
13151312 // is not yet setup and may end up being set up twice if we
13161313 // need to reindex later.
13171314
1318- assert (!g_banman );
1319- g_banman = MakeUnique<BanMan>(GetDataDir () / " banlist.dat" , &uiInterface, gArgs .GetArg (" -bantime" , DEFAULT_MISBEHAVING_BANTIME ));
1320- assert (!g_connman );
1321- g_connman = std::unique_ptr<CConnman>(new CConnman (GetRand (std::numeric_limits<uint64_t >::max ()), GetRand (std::numeric_limits<uint64_t >::max ())));
1315+ assert (!node. banman );
1316+ node. banman = MakeUnique<BanMan>(GetDataDir () / " banlist.dat" , &uiInterface, gArgs .GetArg (" -bantime" , DEFAULT_MISBEHAVING_BANTIME ));
1317+ assert (!node. connman );
1318+ node. connman = std::unique_ptr<CConnman>(new CConnman (GetRand (std::numeric_limits<uint64_t >::max ()), GetRand (std::numeric_limits<uint64_t >::max ())));
13221319
1323- peerLogic. reset (new PeerLogicValidation (g_connman. get (), g_banman .get (), scheduler));
1324- RegisterValidationInterface (peerLogic .get ());
1320+ node. peer_logic . reset (new PeerLogicValidation (node. connman . get (), node. banman .get (), scheduler));
1321+ RegisterValidationInterface (node. peer_logic .get ());
13251322
13261323 // sanitize comments per BIP-0014, format user agent and check total size
13271324 std::vector<std::string> uacomments;
@@ -1766,8 +1763,8 @@ bool AppInitMain(NodeContext& node)
17661763 connOptions.nMaxFeeler = 1 ;
17671764 connOptions.nBestHeight = chain_active_height;
17681765 connOptions.uiInterface = &uiInterface;
1769- connOptions.m_banman = g_banman .get ();
1770- connOptions.m_msgproc = peerLogic .get ();
1766+ connOptions.m_banman = node. banman .get ();
1767+ connOptions.m_msgproc = node. peer_logic .get ();
17711768 connOptions.nSendBufferMaxSize = 1000 *gArgs .GetArg (" -maxsendbuffer" , DEFAULT_MAXSENDBUFFER );
17721769 connOptions.nReceiveFloodSize = 1000 *gArgs .GetArg (" -maxreceivebuffer" , DEFAULT_MAXRECEIVEBUFFER );
17731770 connOptions.m_added_nodes = gArgs .GetArgs (" -addnode" );
@@ -1807,7 +1804,7 @@ bool AppInitMain(NodeContext& node)
18071804 connOptions.m_specified_outgoing = connect;
18081805 }
18091806 }
1810- if (!g_connman ->Start (scheduler, connOptions)) {
1807+ if (!node. connman ->Start (scheduler, connOptions)) {
18111808 return false ;
18121809 }
18131810
@@ -1820,7 +1817,7 @@ bool AppInitMain(NodeContext& node)
18201817 client->start (scheduler);
18211818 }
18221819
1823- BanMan* banman = g_banman .get ();
1820+ BanMan* banman = node. banman .get ();
18241821 scheduler.scheduleEvery ([banman]{
18251822 banman->DumpBanlist ();
18261823 }, DUMP_BANS_INTERVAL * 1000 );
0 commit comments