Function triehash::trie_root [−][src]
pub fn trie_root<H, I, A, B>(input: I) -> H::Out where
I: IntoIterator<Item = (A, B)>,
A: AsRef<[u8]> + Ord,
B: AsRef<[u8]>,
H: Hasher,
<H as Hasher>::Out: Ord,
Generates a trie root hash for a vector of key-value tuples
use hex_literal::hex; use triehash::trie_root; use ethereum_types::H256; use keccak_hasher::KeccakHasher; let v = vec![ ("doe", "reindeer"), ("dog", "puppy"), ("dogglesworth", "cat"), ]; let root = H256::from(hex!("8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3")); assert_eq!(trie_root::<KeccakHasher, _, _, _>(v), root.as_ref());