mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
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>
This commit is contained in:
@@ -49,7 +49,7 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator)
|
||||
}
|
||||
},
|
||||
[&] {
|
||||
std::vector<CTxMemPoolEntry> mempool_entries;
|
||||
std::list<CTxMemPoolEntry> mempool_entries;
|
||||
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000)
|
||||
{
|
||||
const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);
|
||||
@@ -58,7 +58,7 @@ FUZZ_TARGET(policy_estimator, .init = initialize_policy_estimator)
|
||||
break;
|
||||
}
|
||||
const CTransaction tx{*mtx};
|
||||
mempool_entries.push_back(ConsumeTxMemPoolEntry(fuzzed_data_provider, tx));
|
||||
mempool_entries.emplace_back(CTxMemPoolEntry::ExplicitCopy, ConsumeTxMemPoolEntry(fuzzed_data_provider, tx));
|
||||
}
|
||||
std::vector<const CTxMemPoolEntry*> ptrs;
|
||||
ptrs.reserve(mempool_entries.size());
|
||||
|
||||
Reference in New Issue
Block a user