From ade0397f59f2fb59ab0e4ebb39869ac343cc54ee Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 12 Nov 2025 11:20:13 -0500 Subject: [PATCH] txgraph: drop move assignment operator --- src/test/fuzz/txgraph.cpp | 9 +++------ src/txgraph.cpp | 14 -------------- src/txgraph.h | 4 ++-- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/test/fuzz/txgraph.cpp b/src/test/fuzz/txgraph.cpp index fbf22bfc4c3..79ee0a16e44 100644 --- a/src/test/fuzz/txgraph.cpp +++ b/src/test/fuzz/txgraph.cpp @@ -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(); + simmap[simpos] = std::make_shared(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. diff --git a/src/txgraph.cpp b/src/txgraph.cpp index ae85c546716..23094bd8f54 100644 --- a/src/txgraph.cpp +++ b/src/txgraph.cpp @@ -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. diff --git a/src/txgraph.h b/src/txgraph.h index 1d8d31a5427..0e1f2c79d07 100644 --- a/src/txgraph.h +++ b/src/txgraph.h @@ -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.