Skip to content

Commit

Permalink
Refactor Transaction::orchard_nullifiers getter
Browse files Browse the repository at this point in the history
Use the fact that `Option<T>` implements `Iterator<T>` to simplify the
code and remove the need for boxing the iterator.

Co-authored-by: teor <teor@riseup.net>
  • Loading branch information
jvff and teor2345 authored Jun 3, 2021
1 parent e901f82 commit 368edca
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,7 @@ impl Transaction {
}

/// Access the orchard::Nullifiers in this transaction, regardless of version.
pub fn orchard_nullifiers(&self) -> Box<dyn Iterator<Item = &orchard::Nullifier> + '_> {
// This function returns a boxed iterator because the different
// transaction variants can have different iterator types
match self.orchard_shielded_data() {
Some(orchard_shielded_data) => Box::new(orchard_shielded_data.nullifiers()),
None => Box::new(std::iter::empty()),
}
pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
self.orchard_shielded_data().iter().flatten()
}
}

0 comments on commit 368edca

Please sign in to comment.