Implement enumerated trie root throughout.

This commit is contained in:
Gav
2018-01-30 22:40:03 +01:00
parent 69a73f3480
commit e19100e76a
11 changed files with 74 additions and 10 deletions
+8
View File
@@ -20,6 +20,7 @@
extern crate environmental;
extern crate polkadot_state_machine;
extern crate polkadot_primitives as primitives;
extern crate triehash;
use std::fmt;
use primitives::ed25519;
@@ -99,6 +100,13 @@ pub fn storage_root() -> [u8; 32] {
).unwrap_or([0u8; 32])
}
/// "Commit" all existing operations and get the resultant storage root.
pub fn enumerated_trie_root(serialised_values: &[&[u8]]) -> [u8; 32] {
ext::with(|ext|
triehash::ordered_trie_root(serialised_values.iter().map(|s| s.to_vec())).0
).unwrap_or([0u8; 32])
}
/// Conduct a Keccak-256 hash of the given data.
pub use primitives::{blake2_256, twox_128, twox_256};