Skip to content

Commit

Permalink
TO BE SQUASHED: cargo fmt on the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed Aug 31, 2023
1 parent 82b9af4 commit 12c49bf
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions crates/chain/src/tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,25 +1073,37 @@ impl<A> ChangeSet<A> {
/// confirm or exclude these anchors.
///
/// See also: [`Self::missing_heights`]
pub fn relevant_heights(&self) -> impl Iterator<Item=u32> + '_ where A: Anchor {
pub fn relevant_heights(&self) -> impl Iterator<Item = u32> + '_
where
A: Anchor,
{
let mut dedup = None;
self.anchors.iter().map(|(a, _)| a.anchor_block().height).filter(move |height| {
let duplicate = dedup == Some(*height);
dedup = Some(*height);
!duplicate
})
self.anchors
.iter()
.map(|(a, _)| a.anchor_block().height)
.filter(move |height| {
let duplicate = dedup == Some(*height);
dedup = Some(*height);
!duplicate
})
}


/// Returns an iterator for the [`relevant_heights`] in this changeset that are not included in
/// `local_chain`. This tells you which heights you need to include in `local_chain` in order
/// for it to conclusively act as a [`ChainOracle`] for the transaction anchors this changeset
/// will add.
///
/// [`ChainOracle`]: crate::ChainOracle
/// [`relevant_heights`]: Self::relevant_heights
pub fn missing_heights_from<'a>(&'a self, local_chain: &'a LocalChain) -> impl Iterator<Item=u32> + 'a where A: Anchor {
self.relevant_heights().filter(move |height| !local_chain.blocks().contains_key(height))
pub fn missing_heights_from<'a>(
&'a self,
local_chain: &'a LocalChain,
) -> impl Iterator<Item = u32> + 'a
where
A: Anchor,
{
self.relevant_heights()
.filter(move |height| !local_chain.blocks().contains_key(height))
}
}

Expand Down

0 comments on commit 12c49bf

Please sign in to comment.