Reduce usage of Blake2Hasher (#5132)

This reduces the usage of `Blake2Hasher` in the code base and replaces
it with `BlakeTwo256`. The most important change is the removal of the
custom extern function for `Blake2Hasher`. The runtime `Hash` trait is
now also simplified and directly requires that the implementing type
implements `Hashable`.
This commit is contained in:
Benjamin Kampmann
2020-03-05 08:51:03 +01:00
committed by GitHub
parent 406fa981bb
commit 5a33228ea9
64 changed files with 372 additions and 451 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ pub mod system;
use sp_std::{prelude::*, marker::PhantomData};
use codec::{Encode, Decode, Input, Error};
use sp_core::{Blake2Hasher, OpaqueMetadata, RuntimeDebug, ChangesTrieConfiguration};
use sp_core::{OpaqueMetadata, RuntimeDebug, ChangesTrieConfiguration};
use sp_application_crypto::{ed25519, sr25519, RuntimeAppPublic};
use trie_db::{TrieMut, Trie};
use sp_trie::PrefixedMemoryDB;
@@ -419,7 +419,7 @@ fn code_using_trie() -> u64 {
let mut root = sp_std::default::Default::default();
let _ = {
let v = &pairs;
let mut t = TrieDBMut::<Blake2Hasher>::new(&mut mdb, &mut root);
let mut t = TrieDBMut::<BlakeTwo256>::new(&mut mdb, &mut root);
for i in 0..v.len() {
let key: &[u8]= &v[i].0;
let val: &[u8] = &v[i].1;
@@ -430,7 +430,7 @@ fn code_using_trie() -> u64 {
t
};
if let Ok(trie) = TrieDB::<Blake2Hasher>::new(&mdb, &root) {
if let Ok(trie) = TrieDB::<BlakeTwo256>::new(&mdb, &root) {
if let Ok(iter) = trie.iter() {
let mut iter_pairs = Vec::new();
for pair in iter {