@@ -345,10 +345,7 @@ class PeerManagerImpl final : public PeerManager
345
345
* their own locks.
346
346
*/
347
347
std::map<NodeId, PeerRef> m_peer_map GUARDED_BY (m_peer_mutex);
348
- };
349
- } // namespace
350
348
351
- namespace {
352
349
/* * Number of nodes with fSyncStarted. */
353
350
int nSyncStarted GUARDED_BY (cs_main) = 0;
354
351
@@ -360,6 +357,15 @@ namespace {
360
357
*/
361
358
std::map<uint256, std::pair<NodeId, bool >> mapBlockSource GUARDED_BY (cs_main);
362
359
360
+ /* * Number of peers with wtxid relay. */
361
+ int m_wtxid_relay_peers GUARDED_BY (cs_main) = 0;
362
+
363
+ /* * Number of outbound peers with m_chain_sync.m_protect. */
364
+ int m_outbound_peers_with_protect_from_disconnect GUARDED_BY (cs_main) = 0;
365
+ };
366
+ } // namespace
367
+
368
+ namespace {
363
369
/* *
364
370
* Filter for transactions that were recently rejected by
365
371
* AcceptToMemoryPool. These are not rerequested until the chain tip
@@ -423,12 +429,6 @@ namespace {
423
429
/* * Number of peers from which we're downloading blocks. */
424
430
int nPeersWithValidatedDownloads GUARDED_BY (cs_main) = 0;
425
431
426
- /* * Number of peers with wtxid relay. */
427
- int g_wtxid_relay_peers GUARDED_BY (cs_main) = 0;
428
-
429
- /* * Number of outbound peers with m_chain_sync.m_protect. */
430
- int g_outbound_peers_with_protect_from_disconnect GUARDED_BY (cs_main) = 0;
431
-
432
432
/* * When our tip was last updated. */
433
433
std::atomic<int64_t > g_last_tip_update (0 );
434
434
@@ -911,7 +911,7 @@ void PeerManagerImpl::AddTxAnnouncement(const CNode& node, const GenTxid& gtxid,
911
911
auto delay = std::chrono::microseconds{0 };
912
912
const bool preferred = state->fPreferredDownload ;
913
913
if (!preferred) delay += NONPREF_PEER_TX_DELAY;
914
- if (!gtxid.IsWtxid () && g_wtxid_relay_peers > 0 ) delay += TXID_RELAY_DELAY;
914
+ if (!gtxid.IsWtxid () && m_wtxid_relay_peers > 0 ) delay += TXID_RELAY_DELAY;
915
915
const bool overloaded = !node.HasPermission (PF_RELAY) &&
916
916
m_txrequest.CountInFlight (nodeid) >= MAX_PEER_TX_REQUEST_IN_FLIGHT;
917
917
if (overloaded) delay += OVERLOADED_PEER_TX_DELAY;
@@ -1004,10 +1004,10 @@ void PeerManagerImpl::FinalizeNode(const CNode& node, bool& fUpdateConnectionTim
1004
1004
nPreferredDownload -= state->fPreferredDownload ;
1005
1005
nPeersWithValidatedDownloads -= (state->nBlocksInFlightValidHeaders != 0 );
1006
1006
assert (nPeersWithValidatedDownloads >= 0 );
1007
- g_outbound_peers_with_protect_from_disconnect -= state->m_chain_sync .m_protect ;
1008
- assert (g_outbound_peers_with_protect_from_disconnect >= 0 );
1009
- g_wtxid_relay_peers -= state->m_wtxid_relay ;
1010
- assert (g_wtxid_relay_peers >= 0 );
1007
+ m_outbound_peers_with_protect_from_disconnect -= state->m_chain_sync .m_protect ;
1008
+ assert (m_outbound_peers_with_protect_from_disconnect >= 0 );
1009
+ m_wtxid_relay_peers -= state->m_wtxid_relay ;
1010
+ assert (m_wtxid_relay_peers >= 0 );
1011
1011
1012
1012
mapNodeState.erase (nodeid);
1013
1013
@@ -1016,8 +1016,8 @@ void PeerManagerImpl::FinalizeNode(const CNode& node, bool& fUpdateConnectionTim
1016
1016
assert (mapBlocksInFlight.empty ());
1017
1017
assert (nPreferredDownload == 0 );
1018
1018
assert (nPeersWithValidatedDownloads == 0 );
1019
- assert (g_outbound_peers_with_protect_from_disconnect == 0 );
1020
- assert (g_wtxid_relay_peers == 0 );
1019
+ assert (m_outbound_peers_with_protect_from_disconnect == 0 );
1020
+ assert (m_wtxid_relay_peers == 0 );
1021
1021
assert (m_txrequest.Size () == 0 );
1022
1022
}
1023
1023
LogPrint (BCLog::NET, " Cleared nodestate for peer=%d\n " , nodeid);
@@ -2146,10 +2146,10 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
2146
2146
// thus always subject to eviction under the bad/lagging chain logic.
2147
2147
// See ChainSyncTimeoutState.
2148
2148
if (!pfrom.fDisconnect && pfrom.IsFullOutboundConn () && nodestate->pindexBestKnownBlock != nullptr ) {
2149
- if (g_outbound_peers_with_protect_from_disconnect < MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT && nodestate->pindexBestKnownBlock ->nChainWork >= ::ChainActive ().Tip ()->nChainWork && !nodestate->m_chain_sync .m_protect ) {
2149
+ if (m_outbound_peers_with_protect_from_disconnect < MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT && nodestate->pindexBestKnownBlock ->nChainWork >= ::ChainActive ().Tip ()->nChainWork && !nodestate->m_chain_sync .m_protect ) {
2150
2150
LogPrint (BCLog::NET, " Protecting outbound peer=%d from eviction\n " , pfrom.GetId ());
2151
2151
nodestate->m_chain_sync .m_protect = true ;
2152
- ++g_outbound_peers_with_protect_from_disconnect ;
2152
+ ++m_outbound_peers_with_protect_from_disconnect ;
2153
2153
}
2154
2154
}
2155
2155
}
@@ -2759,7 +2759,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2759
2759
LOCK (cs_main);
2760
2760
if (!State (pfrom.GetId ())->m_wtxid_relay ) {
2761
2761
State (pfrom.GetId ())->m_wtxid_relay = true ;
2762
- g_wtxid_relay_peers ++;
2762
+ m_wtxid_relay_peers ++;
2763
2763
} else {
2764
2764
LogPrint (BCLog::NET, " ignoring duplicate wtxidrelay from peer=%d\n " , pfrom.GetId ());
2765
2765
}
0 commit comments