5151#include < optional>
5252#include < typeinfo>
5353
54- /* * How long to cache transactions in mapRelay for normal relay */
55- static constexpr auto RELAY_TX_CACHE_TIME = 15min;
56- /* * How long a transaction has to be in the mempool before it can unconditionally be relayed (even when not in mapRelay). */
54+ /* * How long a transaction has to be in the mempool before it can unconditionally be relayed. */
5755static constexpr auto UNCONDITIONAL_RELAY_DELAY = 2min;
5856/* * Headers download timeout.
5957 * Timeout = base + per_header * (expected number of headers) */
@@ -920,12 +918,6 @@ class PeerManagerImpl final : public PeerManager
920918 /* * Process a new block. Perform any post-processing housekeeping */
921919 void ProcessBlock (CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked);
922920
923- /* * Relay map (txid or wtxid -> CTransactionRef) */
924- typedef std::map<uint256, CTransactionRef> MapRelay;
925- MapRelay mapRelay GUARDED_BY (NetEventsInterface::g_msgproc_mutex);
926- /* * Expiration-time ordered list of (expire time, relay map entry) pairs. */
927- std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY (NetEventsInterface::g_msgproc_mutex);
928-
929921 /* *
930922 * When a peer sends us a valid block, instruct it to announce blocks to us
931923 * using CMPCTBLOCK if possible by adding its nodeid to the end of
@@ -2322,12 +2314,6 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay,
23222314 }
23232315 }
23242316
2325- // Or it might be recent and in the relay pool.
2326- if (recent) {
2327- auto mi = mapRelay.find (gtxid.GetHash ());
2328- if (mi != mapRelay.end ()) return mi->second ;
2329- }
2330-
23312317 return {};
23322318}
23332319
@@ -5796,7 +5782,6 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
57965782 continue ;
57975783 }
57985784 auto txid = txinfo.tx ->GetHash ();
5799- auto wtxid = txinfo.tx ->GetWitnessHash ();
58005785 // Peer told you to not send transactions at that feerate? Don't bother sending it.
58015786 if (txinfo.fee < filterrate.GetFee (txinfo.vsize )) {
58025787 continue ;
@@ -5806,24 +5791,6 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
58065791 tx_relay->m_recently_announced_invs .insert (hash);
58075792 vInv.push_back (inv);
58085793 nRelayedTransactions++;
5809- {
5810- // Expire old relay messages
5811- while (!g_relay_expiration.empty () && g_relay_expiration.front ().first < current_time)
5812- {
5813- mapRelay.erase (g_relay_expiration.front ().second );
5814- g_relay_expiration.pop_front ();
5815- }
5816-
5817- auto ret = mapRelay.emplace (txid, std::move (txinfo.tx ));
5818- if (ret.second ) {
5819- g_relay_expiration.emplace_back (current_time + RELAY_TX_CACHE_TIME, ret.first );
5820- }
5821- // Add wtxid-based lookup into mapRelay as well, so that peers can request by wtxid
5822- auto ret2 = mapRelay.emplace (wtxid, ret.first ->second );
5823- if (ret2.second ) {
5824- g_relay_expiration.emplace_back (current_time + RELAY_TX_CACHE_TIME, ret2.first );
5825- }
5826- }
58275794 if (vInv.size () == MAX_INV_SZ) {
58285795 m_connman.PushMessage (pto, msgMaker.Make (NetMsgType::INV, vInv));
58295796 vInv.clear ();
0 commit comments