mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
[net processin] Don't take cs_main in FindTxForGetData
Taking cs_main is no longer necessary since we moved `m_recently_announced_invs` to `Peer` and `mapRelay` is actually only accessed from the message processing thread.
This commit is contained in:
parent
6b9fedd221
commit
c85ee76a36
1 changed files with 10 additions and 13 deletions
|
@ -909,7 +909,7 @@ private:
|
||||||
|
|
||||||
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
|
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
|
||||||
CTransactionRef FindTxForGetData(const Peer& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
|
CTransactionRef FindTxForGetData(const Peer& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
|
||||||
LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
|
||||||
|
|
||||||
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc)
|
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, peer.m_getdata_requests_mutex, NetEventsInterface::g_msgproc_mutex)
|
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, peer.m_getdata_requests_mutex, NetEventsInterface::g_msgproc_mutex)
|
||||||
|
@ -920,9 +920,9 @@ private:
|
||||||
|
|
||||||
/** Relay map (txid or wtxid -> CTransactionRef) */
|
/** Relay map (txid or wtxid -> CTransactionRef) */
|
||||||
typedef std::map<uint256, CTransactionRef> MapRelay;
|
typedef std::map<uint256, CTransactionRef> MapRelay;
|
||||||
MapRelay mapRelay GUARDED_BY(cs_main);
|
MapRelay mapRelay GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
|
||||||
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
|
||||||
std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY(cs_main);
|
std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a peer sends us a valid block, instruct it to announce blocks to us
|
* When a peer sends us a valid block, instruct it to announce blocks to us
|
||||||
|
@ -2270,16 +2270,13 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer& peer, const GenTxi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// Otherwise, the transaction must have been announced recently.
|
||||||
LOCK(cs_main);
|
if (Assume(peer.GetTxRelay())->m_recently_announced_invs.contains(gtxid.GetHash())) {
|
||||||
// Otherwise, the transaction must have been announced recently.
|
// If it was, it can be relayed from either the mempool...
|
||||||
if (Assume(peer.GetTxRelay())->m_recently_announced_invs.contains(gtxid.GetHash())) {
|
if (txinfo.tx) return std::move(txinfo.tx);
|
||||||
// If it was, it can be relayed from either the mempool...
|
// ... or the relay pool.
|
||||||
if (txinfo.tx) return std::move(txinfo.tx);
|
auto mi = mapRelay.find(gtxid.GetHash());
|
||||||
// ... or the relay pool.
|
if (mi != mapRelay.end()) return mi->second;
|
||||||
auto mi = mapRelay.find(gtxid.GetHash());
|
|
||||||
if (mi != mapRelay.end()) return mi->second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue