@@ -331,23 +331,27 @@ void Cluster::Updated(TxGraphImpl& graph) noexcept
331
331
auto & entry = graph.m_entries [m_mapping[idx]];
332
332
entry.m_locator .SetPresent (this , idx);
333
333
}
334
-
335
- // Compute its chunking and store its information in the Entry's m_chunk_feerate.
336
- LinearizationChunking chunking (m_depgraph, m_linearization);
337
- LinearizationIndex lin_idx{0 };
338
- // Iterate over the chunks.
339
- for (unsigned chunk_idx = 0 ; chunk_idx < chunking.NumChunksLeft (); ++chunk_idx) {
340
- auto chunk = chunking.GetChunk (chunk_idx);
341
- Assume (chunk.transactions .Any ());
342
- // Iterate over the transactions in the linearization, which must match those in chunk.
343
- do {
344
- DepGraphIndex idx = m_linearization[lin_idx++];
345
- GraphIndex graph_idx = m_mapping[idx];
346
- auto & entry = graph.m_entries [graph_idx];
347
- entry.m_chunk_feerate = FeePerWeight::FromFeeFrac (chunk.feerate );
348
- Assume (chunk.transactions [idx]);
349
- chunk.transactions .Reset (idx);
350
- } while (chunk.transactions .Any ());
334
+ // If the Cluster's quality is ACCEPTABLE or OPTIMAL, compute its chunking and store its
335
+ // information in the Entry's m_chunk_feerate. These fields are only accessed after making
336
+ // the entire graph ACCEPTABLE, so it is pointless to compute these if we haven't reached that
337
+ // quality level yet.
338
+ if (IsAcceptable ()) {
339
+ LinearizationChunking chunking (m_depgraph, m_linearization);
340
+ LinearizationIndex lin_idx{0 };
341
+ // Iterate over the chunks.
342
+ for (unsigned chunk_idx = 0 ; chunk_idx < chunking.NumChunksLeft (); ++chunk_idx) {
343
+ auto chunk = chunking.GetChunk (chunk_idx);
344
+ Assume (chunk.transactions .Any ());
345
+ // Iterate over the transactions in the linearization, which must match those in chunk.
346
+ do {
347
+ DepGraphIndex idx = m_linearization[lin_idx++];
348
+ GraphIndex graph_idx = m_mapping[idx];
349
+ auto & entry = graph.m_entries [graph_idx];
350
+ entry.m_chunk_feerate = FeePerWeight::FromFeeFrac (chunk.feerate );
351
+ Assume (chunk.transactions [idx]);
352
+ chunk.transactions .Reset (idx);
353
+ } while (chunk.transactions .Any ());
354
+ }
351
355
}
352
356
}
353
357
@@ -409,8 +413,6 @@ bool Cluster::Split(TxGraphImpl& graph) noexcept
409
413
// The existing Cluster is an entire component. Leave it be, but update its quality.
410
414
Assume (todo == m_depgraph.Positions ());
411
415
graph.SetClusterQuality (m_quality, m_setindex, QualityLevel::NEEDS_RELINEARIZE);
412
- // We need to recompute and cache its chunking.
413
- Updated (graph);
414
416
return false ;
415
417
}
416
418
first = false ;
@@ -1262,12 +1264,12 @@ void Cluster::SanityCheck(const TxGraphImpl& graph) const
1262
1264
assert (entry.m_locator .cluster == this );
1263
1265
assert (entry.m_locator .index == lin_pos);
1264
1266
// Check linearization position and chunk feerate.
1265
- if (!linchunking.GetChunk (0 ).transactions [lin_pos]) {
1266
- linchunking.MarkDone (linchunking.GetChunk (0 ).transactions );
1267
- }
1268
- assert (entry.m_chunk_feerate == linchunking.GetChunk (0 ).feerate );
1269
- // If this Cluster has an acceptable quality level, its chunks must be connected.
1270
1267
if (IsAcceptable ()) {
1268
+ if (!linchunking.GetChunk (0 ).transactions [lin_pos]) {
1269
+ linchunking.MarkDone (linchunking.GetChunk (0 ).transactions );
1270
+ }
1271
+ assert (entry.m_chunk_feerate == linchunking.GetChunk (0 ).feerate );
1272
+ // If this Cluster has an acceptable quality level, its chunks must be connected.
1271
1273
assert (m_depgraph.IsConnected (linchunking.GetChunk (0 ).transactions ));
1272
1274
}
1273
1275
}
0 commit comments