Skip to content

Commit

Permalink
use drop for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars committed Dec 18, 2024
1 parent d7eff74 commit c84cf38
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions crates/iota-genesis-builder/src/stardust/process_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ where

fn next(&mut self) -> Option<Self::Item> {
let Some(mut output) = self.outputs.next() else {
debug!("Number of scaled outputs: {}", self.num_scaled_outputs);
return None;
};
if let Ok((_, inner)) = &mut output {
Expand Down Expand Up @@ -160,6 +159,12 @@ where
}
}

impl<I> Drop for ScaleIotaAmountIterator<I> {
fn drop(&mut self) {
debug!("Number of scaled outputs: {}", self.num_scaled_outputs);
}
}

/// Filtering iterator that looks for vesting outputs that can be unlocked and
/// stores them during the iteration. At the end of the iteration it merges all
/// vesting outputs owned by a single address into a unique basic output.
Expand Down Expand Up @@ -218,14 +223,6 @@ where
let Some((address, output_header_with_balance)) =
self.unlocked_address_balances.pop_first()
else {
debug!(
"Number of vesting outputs before merge: {}",
self.vesting_outputs.len()
);
debug!(
"Number of vesting outputs after merging: {}",
self.num_vesting_outputs
);
return None;
};
self.num_vesting_outputs += 1;
Expand All @@ -240,6 +237,19 @@ where
}
}

impl<I> Drop for UnlockedVestingIterator<I> {
fn drop(&mut self) {
debug!(
"Number of vesting outputs before merge: {}",
self.vesting_outputs.len()
);
debug!(
"Number of vesting outputs after merging: {}",
self.num_vesting_outputs
);
}
}

/// Iterator that looks for basic outputs having a tag being the Participation
/// Tag and removes all features from the basic output.
struct ParticipationOutputIterator<I> {
Expand All @@ -265,11 +275,6 @@ where

fn next(&mut self) -> Option<Self::Item> {
let Some(mut output) = self.outputs.next() else {
debug!(
"Number of participation outputs: {}",
self.participation_outputs.len()
);
debug!("Participation outputs: {:?}", self.participation_outputs);
return None;
};
if let Ok((header, inner)) = &mut output {
Expand All @@ -287,6 +292,16 @@ where
}
}

impl<I> Drop for ParticipationOutputIterator<I> {
fn drop(&mut self) {
debug!(
"Number of participation outputs: {}",
self.participation_outputs.len()
);
debug!("Participation outputs: {:?}", self.participation_outputs);
}
}

/// Extension trait that allows simpler methods for chaining filter iterators.
trait IteratorExt: Iterator<Item = Result<(OutputHeader, Output)>> + Sized {
fn scale_iota_amount(self) -> ScaleIotaAmountIterator<Self> {
Expand Down

0 comments on commit c84cf38

Please sign in to comment.