@@ -336,6 +336,27 @@ class TxGraphImpl final : public TxGraph
336336 return a->m_sequence <=> b->m_sequence ;
337337 }
338338
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+
339360public:
340361 /* * Construct a new TxGraphImpl with the specified maximum cluster count. */
341362 explicit TxGraphImpl (DepGraphIndex max_cluster_count) noexcept :
@@ -1887,16 +1908,8 @@ std::strong_ordering TxGraphImpl::CompareMainOrder(const Ref& a, const Ref& b) n
18871908 Assume (locator_b.IsPresent ());
18881909 MakeAcceptable (*locator_a.cluster );
18891910 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));
19001913}
19011914
19021915TxGraph::GraphIndex TxGraphImpl::CountDistinctClusters (std::span<const Ref* const > refs, bool main_only) noexcept
0 commit comments