Skip to content

Commit

Permalink
Make TapTreeIterator use LeafInfo
Browse files Browse the repository at this point in the history
Previously used depth and script tuple missed information about the leaf version. 
All three comprises already existing type `LeafInfo` which was made public in 
previous commits.
  • Loading branch information
dr-orlovsky committed Apr 19, 2022
1 parent 79345fc commit d655ff3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/util/psbt/map/output.rs
Expand Up @@ -169,17 +169,16 @@ pub struct TapTreeIter<'tree> {
}

impl<'tree> Iterator for TapTreeIter<'tree> {
type Item = (u8, &'tree Script);
type Item = &'tree LeafInfo;

#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.leaf_iter.next().map(|leaf_info| {
(leaf_info.merkle_branch.as_inner().len() as u8, &leaf_info.script)
})
self.leaf_iter.next()
}
}

impl<'tree> IntoIterator for &'tree TapTree {
type Item = (u8, &'tree Script);
type Item = &'tree LeafInfo;
type IntoIter = TapTreeIter<'tree>;

fn into_iter(self) -> Self::IntoIter {
Expand Down

0 comments on commit d655ff3

Please sign in to comment.