txgraph: abstract out creation of empty Clusters (refactor)
This commit is contained in:
1 parent
6baf12621f
commit
e93b0f09cc
1 file changed
+15
-3
+15
-3
@@ -578,6 +578,18 @@ public:
|
|||||||
void ClearChunkData(Entry& entry) noexcept;
|
void ClearChunkData(Entry& entry) noexcept;
|
||||||
/** Give an Entry a ChunkData object. */
|
/** Give an Entry a ChunkData object. */
|
||||||
void CreateChunkData(GraphIndex idx, LinearizationIndex chunk_count) noexcept;
|
void CreateChunkData(GraphIndex idx, LinearizationIndex chunk_count) noexcept;
|
||||||
|
/** Create an empty GenericClusterImpl object. */
|
||||||
|
std::unique_ptr<GenericClusterImpl> CreateEmptyGenericCluster() noexcept
|
||||||
|
{
|
||||||
|
return std::make_unique<GenericClusterImpl>(m_next_sequence_counter++);
|
||||||
|
}
|
||||||
|
/** Create an empty Cluster of the appropriate implementation for the specified (maximum) tx
|
||||||
|
* count. */
|
||||||
|
std::unique_ptr<Cluster> CreateEmptyCluster(DepGraphIndex tx_count) noexcept
|
||||||
|
{
|
||||||
|
(void)tx_count;
|
||||||
|
return CreateEmptyGenericCluster();
|
||||||
|
}
|
||||||
|
|
||||||
// Functions for handling Refs.
|
// Functions for handling Refs.
|
||||||
|
|
||||||
@@ -945,7 +957,7 @@ std::vector<Cluster*> TxGraphImpl::GetConflicts() const noexcept
|
|||||||
Cluster* GenericClusterImpl::CopyToStaging(TxGraphImpl& graph) const noexcept
|
Cluster* GenericClusterImpl::CopyToStaging(TxGraphImpl& graph) const noexcept
|
||||||
{
|
{
|
||||||
// Construct an empty Cluster.
|
// Construct an empty Cluster.
|
||||||
auto ret = std::make_unique<GenericClusterImpl>(graph.m_next_sequence_counter++);
|
auto ret = graph.CreateEmptyGenericCluster();
|
||||||
auto ptr = ret.get();
|
auto ptr = ret.get();
|
||||||
// Copy depgraph, mapping, and linearization/
|
// Copy depgraph, mapping, and linearization/
|
||||||
ptr->m_depgraph = m_depgraph;
|
ptr->m_depgraph = m_depgraph;
|
||||||
@@ -1136,7 +1148,7 @@ bool GenericClusterImpl::Split(TxGraphImpl& graph, int level) noexcept
|
|||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
// Construct a new Cluster to hold the found component.
|
// Construct a new Cluster to hold the found component.
|
||||||
auto new_cluster = std::make_unique<GenericClusterImpl>(graph.m_next_sequence_counter++);
|
auto new_cluster = graph.CreateEmptyCluster(component_size);
|
||||||
new_clusters.push_back(new_cluster.get());
|
new_clusters.push_back(new_cluster.get());
|
||||||
// Remember that all the component's transactions go to this new Cluster. The positions
|
// Remember that all the component's transactions go to this new Cluster. The positions
|
||||||
// will be determined below, so use -1 for now.
|
// will be determined below, so use -1 for now.
|
||||||
@@ -1855,7 +1867,7 @@ TxGraph::Ref TxGraphImpl::AddTransaction(const FeePerWeight& feerate) noexcept
|
|||||||
GetRefIndex(ret) = idx;
|
GetRefIndex(ret) = idx;
|
||||||
// Construct a new singleton Cluster (which is necessarily optimally linearized).
|
// Construct a new singleton Cluster (which is necessarily optimally linearized).
|
||||||
bool oversized = uint64_t(feerate.size) > m_max_cluster_size;
|
bool oversized = uint64_t(feerate.size) > m_max_cluster_size;
|
||||||
auto cluster = std::make_unique<GenericClusterImpl>(m_next_sequence_counter++);
|
auto cluster = CreateEmptyCluster(1);
|
||||||
cluster->AppendTransaction(idx, feerate);
|
cluster->AppendTransaction(idx, feerate);
|
||||||
auto cluster_ptr = cluster.get();
|
auto cluster_ptr = cluster.get();
|
||||||
int level = GetTopLevel();
|
int level = GetTopLevel();
|
||||||
|
|||||||
Reference in new issue
Block a user