aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-10-22 12:29:23 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-10-22 12:29:28 +0200
commitc001da306b29c46ef1e7421002c3aba3ff5ed514 (patch)
treeef3e6c3ff1338e464e1581243986f3082cbddec2 /src/txmempool.h
parent4833d1fdf39fb4e3dc45b76960b769d641eca4b8 (diff)
parent4307849256761fe2440d82bbec892d0e8e6b4dd4 (diff)
Merge bitcoin/bitcoin#23325: mempool: delete exists(uint256) function
4307849256761fe2440d82bbec892d0e8e6b4dd4 [mempool] delete exists(uint256) function (glozow) d50fbd4c5b4bc72415854d582cedf94541a46983 create 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. :bug: 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 ACK 4307849256761fe2440d82bbec892d0e8e6b4dd4 jnewbery: Tested and code review ACK 4307849256761fe2440d82bbec892d0e8e6b4dd4 MarcoFalke: review ACK 4307849256761fe2440d82bbec892d0e8e6b4dd4 👘 Tree-SHA512: 8ed167a96f3124b6c14e41073c8358658114ce121a15a4cca2db7a5ac565903a6236e34e88ac03382b8bb8b68e3999abbfc5718bc8c22476554d6b49a5298eec
Diffstat (limited to 'src/txmempool.h')
-rw-r--r--src/txmempool.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/txmempool.h b/src/txmempool.h
index 460e9d0ceb..1fd0c70891 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -782,7 +782,6 @@ public:
}
return (mapTx.count(gtxid.GetHash()) != 0);
}
- bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); }
CTransactionRef get(const uint256& hash) const;
txiter get_iter_from_wtxid(const uint256& wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
@@ -802,7 +801,7 @@ public:
LOCK(cs);
// Sanity check the transaction is in the mempool & insert into
// unbroadcast set.
- if (exists(txid)) m_unbroadcast_txids.insert(txid);
+ if (exists(GenTxid::Txid(txid))) m_unbroadcast_txids.insert(txid);
};
/** Removes a transaction from the unbroadcast set */