diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ea0b747d09b..cf367aac67d 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -856,7 +856,7 @@ private: std::shared_ptr m_most_recent_block GUARDED_BY(m_most_recent_block_mutex); std::shared_ptr m_most_recent_compact_block GUARDED_BY(m_most_recent_block_mutex); uint256 m_most_recent_block_hash GUARDED_BY(m_most_recent_block_mutex); - std::unique_ptr> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex); + std::unique_ptr> m_most_recent_block_txs GUARDED_BY(m_most_recent_block_mutex); // Data about the low-work headers synchronization, aggregated from all peers' HeadersSyncStates. /** Mutex guarding the other m_headers_presync_* variables. */ @@ -2027,7 +2027,7 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha std::async(std::launch::deferred, [&] { return NetMsg::Make(NetMsgType::CMPCTBLOCK, *pcmpctblock); })}; { - auto most_recent_block_txs = std::make_unique>(); + auto most_recent_block_txs = std::make_unique>(); for (const auto& tx : pblock->vtx) { most_recent_block_txs->emplace(tx->GetHash(), tx); most_recent_block_txs->emplace(tx->GetWitnessHash(), tx); @@ -2393,7 +2393,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv& CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, const CInv& inv) { - auto gtxid{ToGenTxid(inv).ToVariant()}; + auto gtxid{ToGenTxid(inv)}; // If a tx was in the mempool prior to the last INV for this peer, permit the request. auto txinfo{std::visit( [&](const auto& id) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) { @@ -2408,7 +2408,7 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, { LOCK(m_most_recent_block_mutex); if (m_most_recent_block_txs != nullptr) { - auto it = m_most_recent_block_txs->find(gtxid.ToUint256()); + auto it = m_most_recent_block_txs->find(gtxid); if (it != m_most_recent_block_txs->end()) return it->second; } } @@ -4011,11 +4011,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, pfrom.fDisconnect = true; return; } - const GenTxid gtxid = ToGenTxid(inv); + const GenTxidVariant gtxid = ToGenTxid(inv); AddKnownTx(*peer, inv.hash); if (!m_chainman.IsInitialBlockDownload()) { - const bool fAlreadyHave{m_txdownloadman.AddTxAnnouncement(pfrom.GetId(), gtxid.ToVariant(), current_time)}; + const bool fAlreadyHave{m_txdownloadman.AddTxAnnouncement(pfrom.GetId(), gtxid, current_time)}; LogDebug(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId()); } } else { @@ -4946,7 +4946,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, if (vInv.size() <= node::MAX_PEER_TX_ANNOUNCEMENTS + MAX_BLOCKS_IN_TRANSIT_PER_PEER) { for (CInv &inv : vInv) { if (inv.IsGenTxMsg()) { - tx_invs.emplace_back(ToGenTxid(inv).ToVariant()); + tx_invs.emplace_back(ToGenTxid(inv)); } } } @@ -5772,7 +5772,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) txinfo.tx->GetWitnessHash().ToUint256() : txinfo.tx->GetHash().ToUint256(), }; - tx_relay->m_tx_inventory_to_send.erase(ToGenTxid(inv).ToVariant()); + tx_relay->m_tx_inventory_to_send.erase(ToGenTxid(inv)); // Don't send transactions that peers will not put into their mempool if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) { diff --git a/src/protocol.cpp b/src/protocol.cpp index bdf0a669863..a8ad50ab728 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -118,8 +118,8 @@ std::vector serviceFlagsToStr(uint64_t flags) return str_flags; } -GenTxid ToGenTxid(const CInv& inv) +GenTxidVariant ToGenTxid(const CInv& inv) { assert(inv.IsGenTxMsg()); - return inv.IsMsgWtx() ? GenTxid::Wtxid(inv.hash) : GenTxid::Txid(inv.hash); + return inv.IsMsgWtx() ? GenTxidVariant{Wtxid::FromUint256(inv.hash)} : GenTxidVariant{Txid::FromUint256(inv.hash)}; } diff --git a/src/protocol.h b/src/protocol.h index 804597b86d8..35b2722afb9 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -526,6 +526,6 @@ public: }; /** Convert a TX/WITNESS_TX/WTX CInv to a GenTxid. */ -GenTxid ToGenTxid(const CInv& inv); +GenTxidVariant ToGenTxid(const CInv& inv); #endif // BITCOIN_PROTOCOL_H