Skip to content

Commit

Permalink
Support blake2_128Concat key hashing (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones authored Jan 6, 2020
1 parent 3aa3598 commit 80663ec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ impl<K: Encode, V: Decode + Clone> StorageMap<K, V> {
let encoded_key = key.encode();
let hash = match self.hasher {
StorageHasher::Blake2_128 => sp_core::blake2_128(&encoded_key).to_vec(),
StorageHasher::Blake2_128Concat => {
// copied from substrate Blake2_128Concat::hash since StorageHasher is not public
sp_core::blake2_128(&encoded_key)
.iter()
.chain(&encoded_key)
.cloned()
.collect::<Vec<_>>()
},
StorageHasher::Blake2_256 => sp_core::blake2_256(&encoded_key).to_vec(),
StorageHasher::Twox128 => sp_core::twox_128(&encoded_key).to_vec(),
StorageHasher::Twox256 => sp_core::twox_256(&encoded_key).to_vec(),
Expand Down

0 comments on commit 80663ec

Please sign in to comment.