mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07:57 +00:00
Disallow Duplicate Best Headers (#653)
* Add test proving bug * Add checks for duplicate headers * Fix Clippy error
This commit is contained in:
committed by
Bastian Köcher
parent
507edb950c
commit
6cd4f5edf1
@@ -521,7 +521,12 @@ impl<T: Config> BridgeStorage for PalletStorage<T> {
|
||||
|
||||
match current_height.cmp(&best_height) {
|
||||
Ordering::Equal => {
|
||||
<BestHeaders<T>>::append(hash);
|
||||
// Want to avoid duplicates in the case where we're writing a finalized header to
|
||||
// storage which also happens to be at the best height the best height
|
||||
let not_duplicate = !<ImportedHeaders<T>>::contains_key(hash);
|
||||
if not_duplicate {
|
||||
<BestHeaders<T>>::append(hash);
|
||||
}
|
||||
}
|
||||
Ordering::Greater => {
|
||||
<BestHeaders<T>>::kill();
|
||||
|
||||
Reference in New Issue
Block a user