From 39f1dc944554218911b0945fff7e6d06f3dab284 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 5 Aug 2020 17:46:31 +0200 Subject: [PATCH] p2p: remove nFetchFlags from NetMsgType TX and INV processing The nFetchFlags code can be removed here because GetFetchFlags() can only add the MSG_WITNESS_FLAG, which is added to the CInv::type field. That CInv is only passed to AlreadyHave() or ToGenTxid(), and neither of those functions do anything different depending on whether the CInv type is MSG_TX or MSG_WITNESS_TX. Co-authored by: John Newbery --- src/net_processing.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 60bdfbe9f5..a01514185d 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2654,14 +2654,12 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty LOCK(cs_main); - uint32_t nFetchFlags = GetFetchFlags(pfrom); const auto current_time = GetTime(); uint256* best_block{nullptr}; for (CInv &inv : vInv) { - if (interruptMsgProc) - return; + if (interruptMsgProc) return; // Ignore INVs that don't match wtxidrelay setting. // Note that orphan parent fetching always uses MSG_TX GETDATAs regardless of the wtxidrelay setting. @@ -2675,10 +2673,6 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty bool fAlreadyHave = AlreadyHave(inv, m_mempool); LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId()); - if (inv.IsMsgTx()) { - inv.type |= nFetchFlags; - } - if (inv.type == MSG_BLOCK) { UpdateBlockAvailability(pfrom.GetId(), inv.hash); if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { @@ -3013,7 +3007,6 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty } } if (!fRejectedParents) { - uint32_t nFetchFlags = GetFetchFlags(pfrom); const auto current_time = GetTime(); for (const uint256& parent_txid : unique_parents) { @@ -3022,7 +3015,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty // wtxidrelay peers. // Eventually we should replace this with an improved // protocol for getting all unconfirmed parents. - CInv _inv(MSG_TX | nFetchFlags, parent_txid); + CInv _inv(MSG_TX, parent_txid); pfrom.AddKnownTx(parent_txid); if (!AlreadyHave(_inv, m_mempool)) RequestTx(State(pfrom.GetId()), ToGenTxid(_inv), current_time); }