Skip to content

Commit

Permalink
Avoid hashing headers twice in verify_justification (paritytech#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 9, 2024
1 parent 23a7681 commit 17355d0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions bridges/primitives/header-chain/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ where
}
}

let ancestry_hashes = justification
.votes_ancestries
.iter()
.map(|h: &Header| h.hash())
.collect();
if visited_hashes != ancestry_hashes {
// both iterators are `BTree*` iterators, so have the same order => safe to compare
if !visited_hashes.iter().eq(ancestry_chain.ancestry.keys()) {
return Err(Error::InvalidPrecommitAncestries);
}

Expand Down

0 comments on commit 17355d0

Please sign in to comment.