Skip to content

Commit 2b1d302

Browse files
committed
txgraph: move some sanity checks from Cluster to TxGraphImpl (refactor)
1 parent d40302f commit 2b1d302

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/txgraph.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,19 +2286,6 @@ void Cluster::SanityCheck(const TxGraphImpl& graph, int level) const
22862286
assert(m_depgraph.PositionRange() == m_mapping.size());
22872287
// The linearization for this Cluster must contain every transaction once.
22882288
assert(m_depgraph.TxCount() == m_linearization.size());
2289-
// The number of transactions in a Cluster cannot exceed m_max_cluster_count.
2290-
assert(m_linearization.size() <= graph.m_max_cluster_count);
2291-
// The level must match the Cluster's own idea of its level (but GetLevel can only be called
2292-
// for non-empty Clusters).
2293-
assert(GetTxCount() == 0 || level == GetLevel(graph));
2294-
// The sum of their sizes cannot exceed m_max_cluster_size, unless it is an individually
2295-
// oversized transaction singleton. Note that groups of to-be-merged clusters which would
2296-
// exceed this limit are marked oversized, which means they are never applied.
2297-
assert(m_quality == QualityLevel::OVERSIZED_SINGLETON || GetTotalTxSize() <= graph.m_max_cluster_size);
2298-
// m_quality and m_setindex are checked in TxGraphImpl::SanityCheck.
2299-
2300-
// OVERSIZED clusters are singletons.
2301-
assert(m_quality != QualityLevel::OVERSIZED_SINGLETON || m_linearization.size() == 1);
23022289

23032290
// Compute the chunking of m_linearization.
23042291
LinearizationChunking linchunking(m_depgraph, m_linearization);
@@ -2416,6 +2403,19 @@ void TxGraphImpl::SanityCheck() const
24162403
// ... for all clusters in them ...
24172404
for (ClusterSetIndex setindex = 0; setindex < quality_clusters.size(); ++setindex) {
24182405
const auto& cluster = *quality_clusters[setindex];
2406+
// The number of transactions in a Cluster cannot exceed m_max_cluster_count.
2407+
assert(cluster.GetTxCount() <= m_max_cluster_count);
2408+
// The level must match the Cluster's own idea of what level it is in (but GetLevel
2409+
// can only be called for non-empty Clusters).
2410+
assert(cluster.GetTxCount() == 0 || level == cluster.GetLevel(*this));
2411+
// The sum of their sizes cannot exceed m_max_cluster_size, unless it is an
2412+
// individually oversized transaction singleton. Note that groups of to-be-merged
2413+
// clusters which would exceed this limit are marked oversized, which means they
2414+
// are never applied.
2415+
assert(cluster.IsOversized() || cluster.GetTotalTxSize() <= m_max_cluster_size);
2416+
// OVERSIZED clusters are singletons.
2417+
assert(!cluster.IsOversized() || cluster.GetTxCount() == 1);
2418+
24192419
// Check the sequence number.
24202420
assert(cluster.m_sequence < m_next_sequence_counter);
24212421
assert(sequences.count(cluster.m_sequence) == 0);

0 commit comments

Comments
 (0)