Function trie_root::trie_root[][src]

pub fn trie_root<H, S, I, A, B>(input: I, threshold: Option<u32>) -> H::Out where
    I: IntoIterator<Item = (A, B)>,
    A: AsRef<[u8]> + Ord,
    B: AsRef<[u8]>,
    H: Hasher,
    S: TrieStream
Expand description

Generates a trie root hash for a vector of key-value tuples

use hex_literal::hex;
use trie_root::trie_root;
use reference_trie::ReferenceTrieStream;
use keccak_hasher::KeccakHasher;

let v = vec![
    ("doe", "reindeer"),
    ("dog", "puppy"),
    ("dogglesworth", "cat"),
];

let root = hex!["0807d5393ae7f349481063ebb5dbaf6bda58db282a385ca97f37dccba717cb79"];
assert_eq!(trie_root::<KeccakHasher, ReferenceTrieStream, _, _, _>(v), root);