mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-06 13:09:43 +01:00
Merge bitcoin/bitcoin#23325: mempool: delete exists(uint256) function
4307849256[mempool] delete exists(uint256) function (glozow)d50fbd4c5bcreate explicit GenTxid::{Txid, Wtxid} ctors (glozow) Pull request description: We use the same type for txids and wtxids, `uint256`. In places where we want the ability to pass either one, we distinguish them using `GenTxid`. The (overloaded) `CTxMemPool::exists()` function is defined as follows: ```c bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); } ``` It always assumes that a uint256 is a txid, which is a footgunny interface. Querying by wtxid returns a false negative if the transaction has a witness. 🐛 Another approach would be to try both: ```c bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}) || exists(GenTxid{false, txid}); } ``` But that's slower and wrongfully placing the burden on the callee; the caller always knows whether the hash is a txid or a wtxid. ACKs for top commit: laanwj: Code review ACK4307849256jnewbery: Tested and code review ACK4307849256MarcoFalke: review ACK4307849256👘 Tree-SHA512: 8ed167a96f3124b6c14e41073c8358658114ce121a15a4cca2db7a5ac565903a6236e34e88ac03382b8bb8b68e3999abbfc5718bc8c22476554d6b49a5298eec
This commit is contained in:
@@ -3247,7 +3247,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
// Always relay transactions received from peers with forcerelay
|
||||
// permission, even if they were already in the mempool, allowing
|
||||
// the node to function as a gateway for nodes hidden behind it.
|
||||
if (!m_mempool.exists(tx.GetHash())) {
|
||||
if (!m_mempool.exists(GenTxid::Txid(tx.GetHash()))) {
|
||||
LogPrintf("Not relaying non-mempool transaction %s from forcerelay peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
||||
} else {
|
||||
LogPrintf("Force relaying tx %s from peer=%d\n", tx.GetHash().ToString(), pfrom.GetId());
|
||||
|
||||
Reference in New Issue
Block a user