TxGraph: change m_excluded_clusters

Change BlockBuilderImpl's m_excluded_clusters to unordered
set since ordering is not used.

Change the set to a set of sequence numbers for a modest
stability increase under fuzz testing.
This commit is contained in:
Greg Sanders 2025-09-23 12:19:23 -04:00
parent 89144eb473
commit e446f893fc
1 changed files with 6 additions and 4 deletions

View File

@ -15,6 +15,7 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <span> #include <span>
#include <unordered_set>
#include <utility> #include <utility>
namespace { namespace {
@ -98,6 +99,7 @@ struct TrimTxData
class Cluster class Cluster
{ {
friend class TxGraphImpl; friend class TxGraphImpl;
friend class BlockBuilderImpl;
using GraphIndex = TxGraph::GraphIndex; using GraphIndex = TxGraph::GraphIndex;
using SetType = BitSet<MAX_CLUSTER_COUNT_LIMIT>; using SetType = BitSet<MAX_CLUSTER_COUNT_LIMIT>;
/** The DepGraph for this cluster, holding all feerates, and ancestors/descendants. */ /** The DepGraph for this cluster, holding all feerates, and ancestors/descendants. */
@ -643,8 +645,8 @@ class BlockBuilderImpl final : public TxGraph::BlockBuilder
/** Which TxGraphImpl this object is doing block building for. It will have its /** Which TxGraphImpl this object is doing block building for. It will have its
* m_main_chunkindex_observers incremented as long as this BlockBuilderImpl exists. */ * m_main_chunkindex_observers incremented as long as this BlockBuilderImpl exists. */
TxGraphImpl* const m_graph; TxGraphImpl* const m_graph;
/** Clusters which we're not including further transactions from. */ /** Cluster sequence numbers which we're not including further transactions from. */
std::set<Cluster*> m_excluded_clusters; std::unordered_set<uint64_t> m_excluded_clusters;
/** Iterator to the current chunk in the chunk index. end() if nothing further remains. */ /** Iterator to the current chunk in the chunk index. end() if nothing further remains. */
TxGraphImpl::ChunkIndex::const_iterator m_cur_iter; TxGraphImpl::ChunkIndex::const_iterator m_cur_iter;
/** Which cluster the current chunk belongs to, so we can exclude further transactions from it /** Which cluster the current chunk belongs to, so we can exclude further transactions from it
@ -2546,7 +2548,7 @@ void BlockBuilderImpl::Next() noexcept
m_cur_cluster = chunk_end_entry.m_locator[0].cluster; m_cur_cluster = chunk_end_entry.m_locator[0].cluster;
m_known_end_of_cluster = false; m_known_end_of_cluster = false;
// If we previously skipped a chunk from this cluster we cannot include more from it. // If we previously skipped a chunk from this cluster we cannot include more from it.
if (!m_excluded_clusters.contains(m_cur_cluster)) break; if (!m_excluded_clusters.contains(m_cur_cluster->m_sequence)) break;
} }
} }
@ -2620,7 +2622,7 @@ void BlockBuilderImpl::Skip() noexcept
// chunk of the cluster. This may significantly reduce the size of m_excluded_clusters, // chunk of the cluster. This may significantly reduce the size of m_excluded_clusters,
// especially when many singleton clusters are ignored. // especially when many singleton clusters are ignored.
if (m_cur_cluster != nullptr && !m_known_end_of_cluster) { if (m_cur_cluster != nullptr && !m_known_end_of_cluster) {
m_excluded_clusters.insert(m_cur_cluster); m_excluded_clusters.insert(m_cur_cluster->m_sequence);
} }
Next(); Next();
} }