| 1939 | } |
| 1940 | |
| 1941 | CTransactionRef PeerManagerImpl::FindTxForGetData(const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) |
| 1942 | { |
| 1943 | auto txinfo = m_mempool.info(gtxid); |
| 1944 | if (txinfo.tx) { |
| 1945 | // If a TX could have been INVed in reply to a MEMPOOL request, |
| 1946 | // or is older than UNCONDITIONAL_RELAY_DELAY, permit the request |
| 1947 | // unconditionally. |
| 1948 | if ((mempool_req.count() && txinfo.m_time <= mempool_req) || txinfo.m_time <= now - UNCONDITIONAL_RELAY_DELAY) { |
| 1949 | return std::move(txinfo.tx); |
| 1950 | } |
| 1951 | } |
| 1952 | |
| 1953 | { |
| 1954 | LOCK(cs_main); |
| 1955 | // Otherwise, the transaction must have been announced recently. |
| 1956 | if (State(peer.GetId())->m_recently_announced_invs.contains(gtxid.GetHash())) { |
| 1957 | // If it was, it can be relayed from either the mempool... |
| 1958 | if (txinfo.tx) return std::move(txinfo.tx); |
| 1959 | // ... or the relay pool. |
| 1960 | auto mi = mapRelay.find(gtxid.GetHash()); |
| 1961 | if (mi != mapRelay.end()) return mi->second; |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | return {}; |
| 1966 | } |
| 1967 | |
| 1968 | void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) |
| 1969 | { |