Function ethcore_util::triehash::trie_root [] [src]

pub fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> H256

Generates a trie root hash for a vector of key-values

extern crate ethcore_util as util;
use std::str::FromStr;
use util::triehash::*;
use util::hash::*;

fn main() {
    let v = vec![
        (From::from("doe"), From::from("reindeer")),
        (From::from("dog"), From::from("puppy")),
        (From::from("dogglesworth"), From::from("cat")),
    ];

    let root = "8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3";
    assert_eq!(trie_root(v), H256::from_str(root).unwrap());
}