Allow moving CTxMemPoolEntry objects, disallow copying

This commit is contained in:
Suhas Daftuar
2025-01-09 10:30:12 -05:00
parent 6c73e47448
commit 92b0079fe3
2 changed files with 3 additions and 9 deletions

View File

@@ -71,10 +71,7 @@ public:
typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> 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; }

View File

@@ -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<RemovedMempoolTransactionInfo> txs;
txs.reserve(mempool_entries.size());