Avoid hashing headers twice in verify_justification (#973)

This commit is contained in:
Svyatoslav Nikolsky
2021-05-20 02:09:13 +03:00
committed by Bastian Köcher
parent f8f8f42a89
commit b6efe6f740
@@ -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);
}