Skip to content

Commit 34207b9

Browse files
committed
net_processing: move FindTxForGetData and ProcessGetData to PeerManagerImpl
Allows making mapRelay and vRelayExpiration members rather than globals.
1 parent d440848 commit 34207b9

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/net_processing.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,19 @@ class PeerManagerImpl final : public PeerManager
440440

441441
/** When our tip was last updated. */
442442
std::atomic<int64_t> m_last_tip_update{0};
443+
444+
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
445+
CTransactionRef FindTxForGetData(const CTxMemPool& mempool, const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main);
446+
447+
void ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, CConnman& connman, CTxMemPool& mempool, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex);
448+
449+
/** Relay map (txid or wtxid -> CTransactionRef) */
450+
typedef std::map<uint256, CTransactionRef> MapRelay;
451+
MapRelay mapRelay GUARDED_BY(cs_main);
452+
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
453+
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
454+
455+
443456
};
444457
} // namespace
445458

@@ -453,12 +466,6 @@ namespace {
453466
/** Number of peers from which we're downloading blocks. */
454467
int nPeersWithValidatedDownloads GUARDED_BY(cs_main) = 0;
455468

456-
/** Relay map (txid or wtxid -> CTransactionRef) */
457-
typedef std::map<uint256, CTransactionRef> MapRelay;
458-
MapRelay mapRelay GUARDED_BY(cs_main);
459-
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
460-
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
461-
462469
struct IteratorComparator
463470
{
464471
template<typename I>
@@ -1844,8 +1851,7 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
18441851
}
18451852
}
18461853

1847-
//! Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).
1848-
static CTransactionRef FindTxForGetData(const CTxMemPool& mempool, const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
1854+
CTransactionRef PeerManagerImpl::FindTxForGetData(const CTxMemPool& mempool, const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
18491855
{
18501856
auto txinfo = mempool.info(gtxid);
18511857
if (txinfo.tx) {
@@ -1872,7 +1878,7 @@ static CTransactionRef FindTxForGetData(const CTxMemPool& mempool, const CNode&
18721878
return {};
18731879
}
18741880

1875-
void static ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, CConnman& connman, CTxMemPool& mempool, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex)
1881+
void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainparams, CConnman& connman, CTxMemPool& mempool, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!cs_main, peer.m_getdata_requests_mutex)
18761882
{
18771883
AssertLockNotHeld(cs_main);
18781884

0 commit comments

Comments
 (0)