@@ -85,9 +85,6 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
85
85
// Dump addresses to banlist.dat every 15 minutes (900s)
86
86
static constexpr int DUMP_BANS_INTERVAL = 60 * 15 ;
87
87
88
- std::unique_ptr<CConnman> g_connman;
89
- std::unique_ptr<PeerLogicValidation> peerLogic;
90
- std::unique_ptr<BanMan> g_banman;
91
88
92
89
#ifdef WIN32
93
90
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
@@ -163,8 +160,8 @@ void Interrupt(NodeContext& node)
163
160
InterruptREST ();
164
161
InterruptTorControl ();
165
162
InterruptMapPort ();
166
- if (g_connman )
167
- g_connman ->Interrupt ();
163
+ if (node. connman )
164
+ node. connman ->Interrupt ();
168
165
if (g_txindex) {
169
166
g_txindex->Interrupt ();
170
167
}
@@ -197,8 +194,8 @@ void Shutdown(NodeContext& node)
197
194
198
195
// Because these depend on each-other, we make sure that neither can be
199
196
// 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 ();
202
199
if (g_txindex) g_txindex->Stop ();
203
200
ForEachBlockFilterIndex ([](BlockFilterIndex& index ) { index .Stop (); });
204
201
@@ -211,9 +208,9 @@ void Shutdown(NodeContext& node)
211
208
212
209
// After the threads that potentially access these pointers have been stopped,
213
210
// 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 ();
217
214
g_txindex.reset ();
218
215
DestroyAllBlockFilterIndexes ();
219
216
@@ -1315,13 +1312,13 @@ bool AppInitMain(NodeContext& node)
1315
1312
// is not yet setup and may end up being set up twice if we
1316
1313
// need to reindex later.
1317
1314
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 ())));
1322
1319
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 ());
1325
1322
1326
1323
// sanitize comments per BIP-0014, format user agent and check total size
1327
1324
std::vector<std::string> uacomments;
@@ -1766,8 +1763,8 @@ bool AppInitMain(NodeContext& node)
1766
1763
connOptions.nMaxFeeler = 1 ;
1767
1764
connOptions.nBestHeight = chain_active_height;
1768
1765
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 ();
1771
1768
connOptions.nSendBufferMaxSize = 1000 *gArgs .GetArg (" -maxsendbuffer" , DEFAULT_MAXSENDBUFFER);
1772
1769
connOptions.nReceiveFloodSize = 1000 *gArgs .GetArg (" -maxreceivebuffer" , DEFAULT_MAXRECEIVEBUFFER);
1773
1770
connOptions.m_added_nodes = gArgs .GetArgs (" -addnode" );
@@ -1807,7 +1804,7 @@ bool AppInitMain(NodeContext& node)
1807
1804
connOptions.m_specified_outgoing = connect;
1808
1805
}
1809
1806
}
1810
- if (!g_connman ->Start (scheduler, connOptions)) {
1807
+ if (!node. connman ->Start (scheduler, connOptions)) {
1811
1808
return false ;
1812
1809
}
1813
1810
@@ -1820,7 +1817,7 @@ bool AppInitMain(NodeContext& node)
1820
1817
client->start (scheduler);
1821
1818
}
1822
1819
1823
- BanMan* banman = g_banman .get ();
1820
+ BanMan* banman = node. banman .get ();
1824
1821
scheduler.scheduleEvery ([banman]{
1825
1822
banman->DumpBanlist ();
1826
1823
}, DUMP_BANS_INTERVAL * 1000 );
0 commit comments