From 34a6cbb8d2a9a0b4b6566adeff482052c03677da Mon Sep 17 00:00:00 2001 From: Quake Wang Date: Tue, 18 Jul 2023 08:21:26 +0900 Subject: [PATCH] chore: reverse peaks if needed --- src/mmr.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mmr.rs b/src/mmr.rs index 0676aa1..fcd32c4 100644 --- a/src/mmr.rs +++ b/src/mmr.rs @@ -320,16 +320,13 @@ impl> MerkleProof { }; 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();