Skip to content

Commit

Permalink
chore: reverse peaks if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
quake authored Jul 17, 2023
1 parent 91e624f commit 34a6cbb
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/mmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,13 @@ impl<T: Clone + PartialEq, M: Merge<Item = T>> MerkleProof<T, M> {
};
let current_peaks_positions = get_peaks(self.mmr_size);

let mut reverse_index = prev_peaks_positions.len();
let mut reverse_index = prev_peaks_positions.len() - 1;
for (i, position) in prev_peaks_positions.iter().enumerate() {
if *position < current_peaks_positions[i] {
reverse_index = i;
break;
}
}
if reverse_index == prev_peaks_positions.len() {
reverse_index = prev_peaks_positions.len() - 1;
}
let mut prev_peaks: Vec<_> = self.proof_items().to_vec();
let mut reverse_peaks = prev_peaks.split_off(reverse_index);
reverse_peaks.reverse();
Expand Down

0 comments on commit 34a6cbb

Please sign in to comment.