From 92b0079fe3863b20b71282aa82341d4b6ee4b337 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Thu, 9 Jan 2025 10:30:12 -0500 Subject: [PATCH] Allow moving CTxMemPoolEntry objects, disallow copying --- src/kernel/mempool_entry.h | 10 ++-------- src/test/fuzz/policy_estimator.cpp | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h index 51a1f26642f..40aa77b5769 100644 --- a/src/kernel/mempool_entry.h +++ b/src/kernel/mempool_entry.h @@ -71,10 +71,7 @@ public: typedef std::set Children; private: - CTxMemPoolEntry(const CTxMemPoolEntry&) = default; - struct ExplicitCopyTag { - explicit ExplicitCopyTag() = default; - }; + CTxMemPoolEntry(const CTxMemPoolEntry&) = delete; const CTransactionRef tx; mutable Parents m_parents; @@ -127,13 +124,10 @@ public: nModFeesWithAncestors{nFee}, nSigOpCostWithAncestors{sigOpCost} {} - CTxMemPoolEntry(ExplicitCopyTag, const CTxMemPoolEntry& entry) : CTxMemPoolEntry(entry) {} CTxMemPoolEntry& operator=(const CTxMemPoolEntry&) = delete; - CTxMemPoolEntry(CTxMemPoolEntry&&) = delete; + CTxMemPoolEntry(CTxMemPoolEntry&&) = default; 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; } diff --git a/src/test/fuzz/policy_estimator.cpp b/src/test/fuzz/policy_estimator.cpp index 8455a23284d..cfd50cf80d9 100644 --- a/src/test/fuzz/policy_estimator.cpp +++ b/src/test/fuzz/policy_estimator.cpp @@ -74,7 +74,7 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator) break; } const CTransaction tx{*mtx}; - mempool_entries.emplace_back(CTxMemPoolEntry::ExplicitCopy, ConsumeTxMemPoolEntry(fuzzed_data_provider, tx, current_height)); + mempool_entries.push_back(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx, current_height)); } std::vector txs; txs.reserve(mempool_entries.size());