@@ -578,6 +578,18 @@ class TxGraphImpl final : public TxGraph
578578 void ClearChunkData (Entry& entry) noexcept ;
579579 /* * Give an Entry a ChunkData object. */
580580 void CreateChunkData (GraphIndex idx, LinearizationIndex chunk_count) noexcept ;
581+ /* * Create an empty GenericClusterImpl object. */
582+ std::unique_ptr<GenericClusterImpl> CreateEmptyGenericCluster () noexcept
583+ {
584+ return std::make_unique<GenericClusterImpl>(m_next_sequence_counter++);
585+ }
586+ /* * Create an empty Cluster of the appropriate implementation for the specified (maximum) tx
587+ * count. */
588+ std::unique_ptr<Cluster> CreateEmptyCluster (DepGraphIndex tx_count) noexcept
589+ {
590+ (void )tx_count;
591+ return CreateEmptyGenericCluster ();
592+ }
581593
582594 // Functions for handling Refs.
583595
@@ -945,7 +957,7 @@ std::vector<Cluster*> TxGraphImpl::GetConflicts() const noexcept
945957Cluster* GenericClusterImpl::CopyToStaging (TxGraphImpl& graph) const noexcept
946958{
947959 // Construct an empty Cluster.
948- auto ret = std::make_unique<GenericClusterImpl>( graph.m_next_sequence_counter ++ );
960+ auto ret = graph.CreateEmptyGenericCluster ( );
949961 auto ptr = ret.get ();
950962 // Copy depgraph, mapping, and linearization/
951963 ptr->m_depgraph = m_depgraph;
@@ -1136,7 +1148,7 @@ bool GenericClusterImpl::Split(TxGraphImpl& graph, int level) noexcept
11361148 }
11371149 first = false ;
11381150 // Construct a new Cluster to hold the found component.
1139- auto new_cluster = std::make_unique<GenericClusterImpl>( graph.m_next_sequence_counter ++ );
1151+ auto new_cluster = graph.CreateEmptyCluster (component_size );
11401152 new_clusters.push_back (new_cluster.get ());
11411153 // Remember that all the component's transactions go to this new Cluster. The positions
11421154 // will be determined below, so use -1 for now.
@@ -1855,7 +1867,7 @@ TxGraph::Ref TxGraphImpl::AddTransaction(const FeePerWeight& feerate) noexcept
18551867 GetRefIndex (ret) = idx;
18561868 // Construct a new singleton Cluster (which is necessarily optimally linearized).
18571869 bool oversized = uint64_t (feerate.size ) > m_max_cluster_size;
1858- auto cluster = std::make_unique<GenericClusterImpl>(m_next_sequence_counter++ );
1870+ auto cluster = CreateEmptyCluster ( 1 );
18591871 cluster->AppendTransaction (idx, feerate);
18601872 auto cluster_ptr = cluster.get ();
18611873 int level = GetTopLevel ();
0 commit comments