diff --git a/src/net.h b/src/net.h --- a/src/net.h +++ b/src/net.h @@ -695,7 +695,7 @@ CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_inventory); // Set of transaction ids we still have to announce. They are sorted by the // mempool before relay, so the order is not important. - std::set setInventoryTxToSend; + std::set setInventoryTxToSend; // List of block ids we still have announce. There is no final sorting // before sending, as they are always sent immediately and in the order // requested. @@ -813,8 +813,9 @@ void PushInventory(const CInv &inv) { LOCK(cs_inventory); if (inv.type == MSG_TX) { - if (!filterInventoryKnown.contains(inv.hash)) { - setInventoryTxToSend.insert(inv.hash); + const TxId txid(inv.hash); + if (!filterInventoryKnown.contains(txid)) { + setInventoryTxToSend.insert(txid); } } else if (inv.type == MSG_BLOCK) { vInventoryBlockToSend.push_back(inv.hash); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1409,7 +1409,7 @@ // diminishing returns with 2 onward. const TxId txid(inv.hash); return recentRejects->contains(inv.hash) || - g_mempool.exists(inv.hash) || + g_mempool.exists(txid) || pcoinsTip->HaveCoinInCache(COutPoint(txid, 0)) || pcoinsTip->HaveCoinInCache(COutPoint(txid, 1)); } @@ -1674,7 +1674,7 @@ msgMaker.Make(nSendFlags, NetMsgType::TX, *mi->second)); push = true; } else if (pfrom->timeLastMempoolReq) { - auto txinfo = g_mempool.info(inv.hash); + auto txinfo = g_mempool.info(TxId(inv.hash)); // To protect privacy, do not answer getdata using the mempool // when that TX couldn't have been INVed in reply to a MEMPOOL // request. @@ -4016,10 +4016,11 @@ public: explicit CompareInvMempoolOrder(CTxMemPool *_mempool) { mp = _mempool; } - bool operator()(std::set::iterator a, - std::set::iterator b) { - /* As std::make_heap produces a max-heap, we want the entries with the - * fewest ancestors/highest fee to sort later. */ + bool operator()(std::set::iterator a, std::set::iterator b) { + /** + * As std::make_heap produces a max-heap, we want the entries with the + * fewest ancestors/highest fee to sort later. + */ return mp->CompareDepthAndScore(*b, *a); } }; @@ -4379,7 +4380,7 @@ LOCK(pto->cs_filter); for (const auto &txinfo : vtxinfo) { - const uint256 &txid = txinfo.tx->GetId(); + const TxId &txid = txinfo.tx->GetId(); CInv inv(MSG_TX, txid); pto->setInventoryTxToSend.erase(txid); if (filterrate != Amount::zero() && @@ -4404,9 +4405,9 @@ // Determine transactions to relay if (fSendTrickle) { // Produce a vector with all candidates for sending - std::vector::iterator> vInvTx; + std::vector::iterator> vInvTx; vInvTx.reserve(pto->setInventoryTxToSend.size()); - for (std::set::iterator it = + for (std::set::iterator it = pto->setInventoryTxToSend.begin(); it != pto->setInventoryTxToSend.end(); it++) { vInvTx.push_back(it); @@ -4434,17 +4435,17 @@ // Fetch the top element from the heap std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); - std::set::iterator it = vInvTx.back(); + std::set::iterator it = vInvTx.back(); vInvTx.pop_back(); - uint256 hash = *it; + TxId txid = *it; // Remove it from the to-be-sent set pto->setInventoryTxToSend.erase(it); // Check if not in the filter already - if (pto->filterInventoryKnown.contains(hash)) { + if (pto->filterInventoryKnown.contains(txid)) { continue; } // Not in the mempool anymore? don't bother sending it. - auto txinfo = g_mempool.info(hash); + auto txinfo = g_mempool.info(txid); if (!txinfo.tx) { continue; } @@ -4457,7 +4458,7 @@ continue; } // Send - vInv.push_back(CInv(MSG_TX, hash)); + vInv.push_back(CInv(MSG_TX, txid)); nRelayedTransactions++; { // Expire old relay messages @@ -4468,7 +4469,7 @@ } auto ret = mapRelay.insert( - std::make_pair(hash, std::move(txinfo.tx))); + std::make_pair(txid, std::move(txinfo.tx))); if (ret.second) { vRelayExpiration.push_back(std::make_pair( nNow + 15 * 60 * 1000000, ret.first)); @@ -4479,7 +4480,7 @@ msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } - pto->filterInventoryKnown.insert(hash); + pto->filterInventoryKnown.insert(txid); } } }