State machine local child root cache. (#9107)

* cache root for child api.

* minimal testing

* Reset cache on test 'set_root'.

* Update primitives/state-machine/src/trie_backend_essence.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update primitives/state-machine/src/trie_backend_essence.rs

* Update primitives/state-machine/src/trie_backend_essence.rs

* Renaming to 'reset_cache'.

* correct rust fmt

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
cheme
2021-07-23 13:30:00 +02:00
committed by GitHub
parent fc2dd61f14
commit ade667f928
2 changed files with 70 additions and 2 deletions
@@ -326,6 +326,22 @@ pub mod tests {
.unwrap(),
Some(vec![142u8]),
);
// Change cache entry to check that caching is active.
test_trie
.essence
.cache
.write()
.child_root
.entry(b"sub1".to_vec())
.and_modify(|value| {
*value = None;
});
assert_eq!(
test_trie
.child_storage(&ChildInfo::new_default(CHILD_KEY_1), b"value3")
.unwrap(),
None,
);
}
#[test]