diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index e16ae88d..a1ddbf87 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -603,11 +603,17 @@ impl TxGraph { impl TxGraph { /// Get all heights that are relevant to the graph. pub fn relevant_heights(&self) -> impl DoubleEndedIterator + '_ { - let mut visited = HashSet::new(); + let mut last_height = Option::::None; self.anchors .iter() .map(|(a, _)| a.anchor_block().height) - .filter(move |&h| visited.insert(h)) + .filter(move |&height| { + let is_unique = Some(height) != last_height; + if is_unique { + last_height = Some(height); + } + is_unique + }) } /// Get the position of the transaction in `chain` with tip `chain_tip`.