pub fn child_delta_trie_root<H: Hasher, I, A, B, DB>(
	_storage_key: &[u8],
	db: &mut DB,
	root_vec: Vec<u8>,
	delta: I
) -> Result<Vec<u8>, Box<TrieError<H::Out>>> where
	I: IntoIterator<Item = (A, Option<B>)>,
	A: AsRef<[u8]> + Ord,
	B: AsRef<[u8]>,
	DB: hash_db::HashDB<H, trie_db::DBValue> + hash_db::PlainDB<H::Out, trie_db::DBValue>,
{
	let mut root = H::Out::default();
	root.as_mut().copy_from_slice(&root_vec); // root is fetched from DB, not writable by runtime, so it's always valid.

	{
		let mut trie = TrieDBMut::<H>::from_existing(&mut *db, &mut root)?;

		for (key, change) in delta {
			match change {
				Some(val) => trie.insert(key.as_ref(), val.as_ref())?,
				None => trie.remove(key.as_ref())?,
			};
		}
	}

	Ok(root.as_ref().to_vec())
}
/// Determine a child trie root given a hash DB and delta values. H is the default hasher, but a generic implementation may ignore this type parameter and use other hashers.
Determine a child trie root given a hash DB and delta values. H is the default hasher, but a generic implementation may ignore this type parameter and use other hashers.
Determine a child trie root given a hash DB and delta values . H is the default hasher but a generic implementation may ignore this type parameter and use other hashers .
pub fn child_delta_trie_root<H: Hasher, I, A, B, DB>(
	_storage_key: &[u8],
	db: &mut DB,
	root_vec: Vec<u8>,
	delta: I
) -> Result<Vec<u8>, Box<TrieError<H::Out>>> where
	I: IntoIterator<Item = (A, Option<B>)>,
	A: AsRef<[u8]> + Ord,
	B: AsRef<[u8]>,
	DB: hash_db::HashDB<H, trie_db::DBValue> + hash_db::PlainDB<H::Out, trie_db::DBValue>,
{
	let mut root = H::Out::default();
	root.as_mut().copy_from_slice(&root_vec); // root is fetched from DB, not writable by runtime, so it's always valid.
	{
		let mut trie = TrieDBMut::<H>::from_existing(&mut *db, &mut root)?;
		for (key, change) in delta {
			match change {
				Some(val) => trie.insert(key.as_ref(), val.as_ref())?,
				None => trie.remove(key.as_ref())?,
			};
		}
	}
	Ok(root.as_ref().to_vec())
}
pub fn child_delta_trie_root < H : Hasher , I , A , B , DB > ( _storage_key : & [ u8 ] , db : & mut DB , root_vec : Vec < u8 > , delta : I ) -> Result < Vec < u8 > , Box < TrieError < H :: Out > > > where I : IntoIterator < Item = ( A , Option < B > ) > , A : AsRef < [ u8 ] > + Ord , B : AsRef < [ u8 ] > , DB : hash_db :: HashDB < H , trie_db :: DBValue > + hash_db :: PlainDB < H :: Out , trie_db :: DBValue > , { let mut root = H :: Out :: default ( ) ; root . as_mut ( ) . copy_from_slice ( & root_vec ) ; // root is fetched from DB, not writable by runtime, so it's always valid. { let mut trie = TrieDBMut :: < H > :: from_existing ( & mut * db , & mut root ) ? ; for ( key , change ) in delta { match change { Some ( val ) => trie . insert ( key . as_ref ( ) , val . as_ref ( ) ) ? , None => trie . remove ( key . as_ref ( ) ) ? , } ; } } Ok ( root . as_ref ( ) . to_vec ( ) ) }
Determine a child trie root given a hash DB and delta values.
Determine a child trie root given a hash DB and delta values .
_storage_key
&[u8]
db
&mut DB
root_vec
Vec<u8>
delta
I
_storage_key
&[u8]
db
&mut DB
root_vec
Vec<u8>
delta
I