aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-11-17 20:28:14 +0100
committerTheCharlatan <seb.kung@gmail.com>2023-11-17 23:02:02 +0100
commit705e3f1de00bf30d728addd52a790a139d948e32 (patch)
tree3a48a2a69d555b000d6b085c210c35074581003b /src/kernel
parent22025d06e53f9bfccf88c600815f1cc496595d5d (diff)
downloadbitcoin-705e3f1de00bf30d728addd52a790a139d948e32.tar.xz
refactor: Make CTxMemPoolEntry only explicitly copyable
This has the goal of prohibiting users from accidentally creating runtime failures, e.g. by interacting with iterator_to with a copied entry. CTxMemPoolEntry is already implicitly not move-constructable. So be explicit about this and use a std::list to collect the values in the policy_estimator fuzz test instead of a std::vector. Co-authored-by: Anthony Towns <aj@erisian.com.au>
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/mempool_entry.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h
index 7c905ca4f4..b5c0499012 100644
--- a/src/kernel/mempool_entry.h
+++ b/src/kernel/mempool_entry.h
@@ -71,6 +71,11 @@ public:
typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Children;
private:
+ CTxMemPoolEntry(const CTxMemPoolEntry&) = default;
+ struct ExplicitCopyTag {
+ explicit ExplicitCopyTag() = default;
+ };
+
const CTransactionRef tx;
mutable Parents m_parents;
mutable Children m_children;
@@ -122,6 +127,13 @@ public:
nModFeesWithAncestors{nFee},
nSigOpCostWithAncestors{sigOpCost} {}
+ CTxMemPoolEntry(ExplicitCopyTag, const CTxMemPoolEntry& entry) : CTxMemPoolEntry(entry) {}
+ CTxMemPoolEntry& operator=(const CTxMemPoolEntry&) = delete;
+ CTxMemPoolEntry(CTxMemPoolEntry&&) = delete;
+ CTxMemPoolEntry& operator=(CTxMemPoolEntry&&) = delete;
+
+ static constexpr ExplicitCopyTag ExplicitCopy{};
+
const CTransaction& GetTx() const { return *this->tx; }
CTransactionRef GetSharedTx() const { return this->tx; }
const CAmount& GetFee() const { return nFee; }