From 08b39955ec7f84e835ab0b1366f0dd28dfd6ce03 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Wed, 29 Jan 2020 10:40:54 -0500 Subject: [PATCH] Add a wtxid-index to mapRelay --- src/net_processing.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1373338cf3..7dd8da307c 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4246,6 +4246,11 @@ bool PeerLogicValidation::SendMessages(CNode* pto) if (ret.second) { vRelayExpiration.push_back(std::make_pair(nNow + std::chrono::microseconds{RELAY_TX_CACHE_TIME}.count(), ret.first)); } + // Add wtxid-based lookup into mapRelay as well, so that peers can request by wtxid + auto ret2 = mapRelay.emplace(ret.first->second->GetWitnessHash(), ret.first->second); + if (ret2.second) { + vRelayExpiration.emplace_back(nNow + std::chrono::microseconds{RELAY_TX_CACHE_TIME}.count(), ret2.first); + } } if (vInv.size() == MAX_INV_SZ) { connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));