MCPcopy Create free account
hub / github.com/ElementsProject/elements / FindTxForGetData

Method FindTxForGetData

src/net_processing.cpp:1941–1966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939}
1940
1941CTransactionRef 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
1968void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc)
1969{

Callers

nothing calls this directly

Calls 8

infoMethod · 0.80
countMethod · 0.80
GetIdMethod · 0.80
findMethod · 0.80
StateEnum · 0.70
containsMethod · 0.45
GetHashMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected