Skip to content

Commit 5c124e1

Browse files
committed
refactor: make FindTxForGetData use GenTxid
1 parent a2bfac8 commit 5c124e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace {
236236
/** When our tip was last updated. */
237237
std::atomic<int64_t> g_last_tip_update(0);
238238

239-
/** Relay map */
239+
/** Relay map (txid or wtxid -> CTransactionRef) */
240240
typedef std::map<uint256, CTransactionRef> MapRelay;
241241
MapRelay mapRelay GUARDED_BY(cs_main);
242242
/** Expiration-time ordered list of (expire time, relay map entry) pairs. */
@@ -1671,9 +1671,9 @@ void static ProcessGetBlockData(CNode& pfrom, const CChainParams& chainparams, c
16711671
}
16721672

16731673
//! Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).
1674-
CTransactionRef static FindTxForGetData(const CNode& peer, const uint256& txid_or_wtxid, bool use_wtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
1674+
CTransactionRef static FindTxForGetData(const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
16751675
{
1676-
auto txinfo = mempool.info(txid_or_wtxid, use_wtxid);
1676+
auto txinfo = mempool.info(gtxid.GetHash(), gtxid.IsWtxid());
16771677
if (txinfo.tx) {
16781678
// If a TX could have been INVed in reply to a MEMPOOL request,
16791679
// or is older than UNCONDITIONAL_RELAY_DELAY, permit the request
@@ -1686,11 +1686,11 @@ CTransactionRef static FindTxForGetData(const CNode& peer, const uint256& txid_o
16861686
{
16871687
LOCK(cs_main);
16881688
// Otherwise, the transaction must have been announced recently.
1689-
if (State(peer.GetId())->m_recently_announced_invs.contains(txid_or_wtxid)) {
1689+
if (State(peer.GetId())->m_recently_announced_invs.contains(gtxid.GetHash())) {
16901690
// If it was, it can be relayed from either the mempool...
16911691
if (txinfo.tx) return std::move(txinfo.tx);
16921692
// ... or the relay pool.
1693-
auto mi = mapRelay.find(txid_or_wtxid);
1693+
auto mi = mapRelay.find(gtxid.GetHash());
16941694
if (mi != mapRelay.end()) return mi->second;
16951695
}
16961696
}
@@ -1727,7 +1727,7 @@ void static ProcessGetData(CNode& pfrom, const CChainParams& chainparams, CConnm
17271727
continue;
17281728
}
17291729

1730-
CTransactionRef tx = FindTxForGetData(pfrom, inv.hash, inv.IsMsgWtx(), mempool_req, now);
1730+
CTransactionRef tx = FindTxForGetData(pfrom, ToGenTxid(inv), mempool_req, now);
17311731
if (tx) {
17321732
// WTX and WITNESS_TX imply we serialize with witness
17331733
int nSendFlags = (inv.IsMsgTx() ? SERIALIZE_TRANSACTION_NO_WITNESS : 0);

0 commit comments

Comments
 (0)