@@ -336,6 +336,27 @@ class TxGraphImpl final : public TxGraph
336
336
return a->m_sequence <=> b->m_sequence ;
337
337
}
338
338
339
+ /* * Compare two entries (which must both exist within the main graph). */
340
+ std::strong_ordering CompareMainTransactions (GraphIndex a, GraphIndex b) const noexcept
341
+ {
342
+ Assume (a < m_entries.size () && b < m_entries.size ());
343
+ const auto & entry_a = m_entries[a];
344
+ const auto & entry_b = m_entries[b];
345
+ // Compare chunk feerates, and return result if it differs.
346
+ auto feerate_cmp = FeeRateCompare (entry_b.m_main_chunk_feerate , entry_a.m_main_chunk_feerate );
347
+ if (feerate_cmp < 0 ) return std::strong_ordering::less;
348
+ if (feerate_cmp > 0 ) return std::strong_ordering::greater;
349
+ // Compare Cluster m_sequence as tie-break for equal chunk feerates.
350
+ const auto & locator_a = entry_a.m_locator [0 ];
351
+ const auto & locator_b = entry_b.m_locator [0 ];
352
+ Assume (locator_a.IsPresent () && locator_b.IsPresent ());
353
+ if (locator_a.cluster != locator_b.cluster ) {
354
+ return CompareClusters (locator_a.cluster , locator_b.cluster );
355
+ }
356
+ // As final tie-break, compare position within cluster linearization.
357
+ return entry_a.m_main_lin_index <=> entry_b.m_main_lin_index ;
358
+ }
359
+
339
360
public:
340
361
/* * Construct a new TxGraphImpl with the specified maximum cluster count. */
341
362
explicit TxGraphImpl (DepGraphIndex max_cluster_count) noexcept :
@@ -1887,16 +1908,8 @@ std::strong_ordering TxGraphImpl::CompareMainOrder(const Ref& a, const Ref& b) n
1887
1908
Assume (locator_b.IsPresent ());
1888
1909
MakeAcceptable (*locator_a.cluster );
1889
1910
MakeAcceptable (*locator_b.cluster );
1890
- // Compare chunk feerates, and return result if it differs.
1891
- auto feerate_cmp = FeeRateCompare (entry_b.m_main_chunk_feerate , entry_a.m_main_chunk_feerate );
1892
- if (feerate_cmp < 0 ) return std::strong_ordering::less;
1893
- if (feerate_cmp > 0 ) return std::strong_ordering::greater;
1894
- // Compare Cluster* as tie-break for equal chunk feerates.
1895
- if (locator_a.cluster != locator_b.cluster ) {
1896
- return CompareClusters (locator_a.cluster , locator_b.cluster );
1897
- }
1898
- // As final tie-break, compare position within cluster linearization.
1899
- return entry_a.m_main_lin_index <=> entry_b.m_main_lin_index ;
1911
+ // Invoke comparison logic.
1912
+ return CompareMainTransactions (GetRefIndex (a), GetRefIndex (b));
1900
1913
}
1901
1914
1902
1915
TxGraph::GraphIndex TxGraphImpl::CountDistinctClusters (std::span<const Ref* const > refs, bool main_only) noexcept
0 commit comments