Skip to content

Commit

Permalink
Prevent bug when reusing type ids in hashing (#1075)
Browse files Browse the repository at this point in the history
* practice TDD

* implement a hashmap 2-phases approach

* use nicer types

* add test for cache filling

* adjust test

---------

Co-authored-by: James Wilson <james@jsdw.me>
  • Loading branch information
tadeohepperle and jsdw authored Jul 19, 2023
1 parent 84df959 commit 475a141
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 61 deletions.
4 changes: 2 additions & 2 deletions metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod from_into;
mod utils;

use scale_info::{form::PortableForm, PortableRegistry, Variant};
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::sync::Arc;
use utils::ordered_map::OrderedMap;
use utils::variant_index::VariantIndex;
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Metadata {
Some(crate::utils::validation::get_type_hash(
&self.types,
id,
&mut HashSet::<u32>::new(),
&mut HashMap::new(),
))
}
}
Expand Down
Loading

0 comments on commit 475a141

Please sign in to comment.