@@ -1609,11 +1609,14 @@ void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, c
1609
1609
}
1610
1610
1611
1611
// ! Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).
1612
- CTransactionRef static FindTxForGetData (const uint256& txid, const std::chrono::seconds mempool_req, const std::chrono::seconds longlived_mempool_time) EXCLUSIVE_LOCKS_REQUIRED (cs_main)
1612
+ CTransactionRef static FindTxForGetData (const uint256& txid, const std::chrono::seconds mempool_req, const std::chrono::seconds longlived_mempool_time) LOCKS_EXCLUDED (cs_main)
1613
1613
{
1614
- // Look up transaction in relay pool
1615
- auto mi = mapRelay.find (txid);
1616
- if (mi != mapRelay.end ()) return mi->second ;
1614
+ {
1615
+ LOCK (cs_main);
1616
+ // Look up transaction in relay pool
1617
+ auto mi = mapRelay.find (txid);
1618
+ if (mi != mapRelay.end ()) return mi->second ;
1619
+ }
1617
1620
1618
1621
auto txinfo = mempool.info (txid);
1619
1622
if (txinfo.tx ) {
@@ -1642,37 +1645,31 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
1642
1645
const std::chrono::seconds mempool_req = pfrom->m_tx_relay != nullptr ? pfrom->m_tx_relay ->m_last_mempool_req .load ()
1643
1646
: std::chrono::seconds::min ();
1644
1647
1645
- {
1646
- LOCK (cs_main);
1647
-
1648
- // Process as many TX items from the front of the getdata queue as
1649
- // possible, since they're common and it's efficient to batch process
1650
- // them.
1651
- while (it != pfrom->vRecvGetData .end () && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) {
1652
- if (interruptMsgProc)
1653
- return ;
1654
- // The send buffer provides backpressure. If there's no space in
1655
- // the buffer, pause processing until the next call.
1656
- if (pfrom->fPauseSend )
1657
- break ;
1648
+ // Process as many TX items from the front of the getdata queue as
1649
+ // possible, since they're common and it's efficient to batch process
1650
+ // them.
1651
+ while (it != pfrom->vRecvGetData .end () && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) {
1652
+ if (interruptMsgProc) return ;
1653
+ // The send buffer provides backpressure. If there's no space in
1654
+ // the buffer, pause processing until the next call.
1655
+ if (pfrom->fPauseSend ) break ;
1658
1656
1659
- const CInv &inv = *it++;
1657
+ const CInv &inv = *it++;
1660
1658
1661
- if (pfrom->m_tx_relay == nullptr ) {
1662
- // Ignore GETDATA requests for transactions from blocks-only peers.
1663
- continue ;
1664
- }
1659
+ if (pfrom->m_tx_relay == nullptr ) {
1660
+ // Ignore GETDATA requests for transactions from blocks-only peers.
1661
+ continue ;
1662
+ }
1665
1663
1666
- CTransactionRef tx = FindTxForGetData (inv.hash , mempool_req, longlived_mempool_time);
1667
- if (tx) {
1668
- int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0 );
1669
- connman->PushMessage (pfrom, msgMaker.Make (nSendFlags, NetMsgType::TX, *tx));
1670
- mempool.RemoveUnbroadcastTx (inv.hash );
1671
- } else {
1672
- vNotFound.push_back (inv);
1673
- }
1664
+ CTransactionRef tx = FindTxForGetData (inv.hash , mempool_req, longlived_mempool_time);
1665
+ if (tx) {
1666
+ int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0 );
1667
+ connman->PushMessage (pfrom, msgMaker.Make (nSendFlags, NetMsgType::TX, *tx));
1668
+ mempool.RemoveUnbroadcastTx (inv.hash );
1669
+ } else {
1670
+ vNotFound.push_back (inv);
1674
1671
}
1675
- } // release cs_main
1672
+ }
1676
1673
1677
1674
// Only process one BLOCK item per call, since they're uncommon and can be
1678
1675
// expensive to process.
0 commit comments