mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge bitcoin/bitcoin#33862: txgraph: drop move assignment operator
ade0397f59txgraph: drop move assignment operator (Anthony Towns) Pull request description: This removes the only place where move-assignment of `TxGraph::Ref` is used (in tests), and drops supports for it. Suggested in https://github.com/bitcoin/bitcoin/pull/33629#discussion_r2518940184 ACKs for top commit: l0rinc: reACKade0397f59instagibbs: ACKade0397f59Tree-SHA512: 0f49e454d0d44817278cbd3fbb8fce89c64c6f6c6d852bea26c728b9f1b6827a0f2b8731ac2031150af92b0ec479c2fe4ece01256fb3b6b2bf941f16c0e2c541
This commit is contained in:
@@ -138,19 +138,18 @@ struct SimTxGraph
|
||||
}
|
||||
|
||||
/** Add a new transaction to the simulation. */
|
||||
TxGraph::Ref* AddTransaction(const FeePerWeight& feerate)
|
||||
void AddTransaction(TxGraph::Ref&& ref, const FeePerWeight& feerate)
|
||||
{
|
||||
assert(graph.TxCount() < MAX_TRANSACTIONS);
|
||||
auto simpos = graph.AddTransaction(feerate);
|
||||
real_is_optimal = false;
|
||||
MakeModified(simpos);
|
||||
assert(graph.Positions()[simpos]);
|
||||
simmap[simpos] = std::make_shared<TxGraph::Ref>();
|
||||
simmap[simpos] = std::make_shared<TxGraph::Ref>(std::move(ref));
|
||||
auto ptr = simmap[simpos].get();
|
||||
simrevmap[ptr] = simpos;
|
||||
// This may invalidate our cached oversized value.
|
||||
if (oversized.has_value() && !*oversized) oversized = std::nullopt;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/** Add a dependency between two positions in this graph. */
|
||||
@@ -459,9 +458,7 @@ FUZZ_TARGET(txgraph)
|
||||
// Create a real TxGraph::Ref.
|
||||
auto ref = real->AddTransaction(feerate);
|
||||
// Create a shared_ptr place in the simulation to put the Ref in.
|
||||
auto ref_loc = top_sim.AddTransaction(feerate);
|
||||
// Move it in place.
|
||||
*ref_loc = std::move(ref);
|
||||
top_sim.AddTransaction(std::move(ref), feerate);
|
||||
break;
|
||||
} else if ((block_builders.empty() || sims.size() > 1) && top_sim.GetTransactionCount() + top_sim.removed.size() > 1 && command-- == 0) {
|
||||
// AddDependency.
|
||||
|
||||
@@ -3451,20 +3451,6 @@ TxGraph::Ref::~Ref()
|
||||
}
|
||||
}
|
||||
|
||||
TxGraph::Ref& TxGraph::Ref::operator=(Ref&& other) noexcept
|
||||
{
|
||||
// Unlink the current graph, if any.
|
||||
if (m_graph) m_graph->UnlinkRef(m_index);
|
||||
// Inform the other's graph about the move, if any.
|
||||
if (other.m_graph) other.m_graph->UpdateRef(other.m_index, *this);
|
||||
// Actually update the contents.
|
||||
m_graph = other.m_graph;
|
||||
m_index = other.m_index;
|
||||
other.m_graph = nullptr;
|
||||
other.m_index = GraphIndex(-1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
TxGraph::Ref::Ref(Ref&& other) noexcept
|
||||
{
|
||||
// Inform the TxGraph of other that its Ref is being moved.
|
||||
|
||||
@@ -241,8 +241,8 @@ public:
|
||||
/** Destroy this Ref. If it is not empty, the corresponding transaction is removed (in both
|
||||
* main and staging, if it exists). */
|
||||
virtual ~Ref();
|
||||
// Support moving a Ref.
|
||||
Ref& operator=(Ref&& other) noexcept;
|
||||
// Support move-constructing a Ref.
|
||||
Ref& operator=(Ref&& other) noexcept = delete;
|
||||
Ref(Ref&& other) noexcept;
|
||||
// Do not permit copy constructing or copy assignment. A TxGraph entry can have at most one
|
||||
// Ref pointing to it.
|
||||
|
||||
Reference in New Issue
Block a user