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 May 19, 2021
1 parent 3b37fa1 commit cbf846b
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 cbf846b

Please sign in to comment.