mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
net_processing: move FindTxForGetData and ProcessGetData to PeerManagerImpl
Allows making mapRelay and vRelayExpiration members rather than globals.
This commit is contained in:
parent
d44084883a
commit
34207b9004
@ -440,6 +440,19 @@ private:
|
||||
|
||||
/** When our tip was last updated. */
|
||||
std::atomic<int64_t> m_last_tip_update{0};
|
||||
|
||||
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/** Relay map (txid or wtxid -> CTransactionRef) */
|
||||
typedef std::map<uint256, CTransactionRef> MapRelay;
|
||||
MapRelay mapRelay GUARDED_BY(cs_main);
|
||||
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
||||
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
|
||||
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -453,12 +466,6 @@ namespace {
|
||||
/** Number of peers from which we're downloading blocks. */
|
||||
int nPeersWithValidatedDownloads GUARDED_BY(cs_main) = 0;
|
||||
|
||||
/** Relay map (txid or wtxid -> CTransactionRef) */
|
||||
typedef std::map<uint256, CTransactionRef> MapRelay;
|
||||
MapRelay mapRelay GUARDED_BY(cs_main);
|
||||
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
||||
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);
|
||||
|
||||
struct IteratorComparator
|
||||
{
|
||||
template<typename I>
|
||||
@ -1844,8 +1851,7 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
|
||||
}
|
||||
}
|
||||
|
||||
//! Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).
|
||||
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)
|
||||
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)
|
||||
{
|
||||
auto txinfo = mempool.info(gtxid);
|
||||
if (txinfo.tx) {
|
||||
@ -1872,7 +1878,7 @@ static CTransactionRef FindTxForGetData(const CTxMemPool& mempool, const CNode&
|
||||
return {};
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
AssertLockNotHeld(cs_main);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user