Make triecache generic and work for no-std environments (#14403)

* Remove `AsLocalTrieCache` trait

* Introduce new trait AsTrieDbCache

* Use AsTrieDbCache trait

* Make it compile

* Docs

* Improve naming of associated type, implement cache usage for no-std

* Improve naming

* Improve docs

* Allow construction with optional cache

* FMT

* Remove unused variable

* Revert unwanted change

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* More comment adjustments

* Docs

* Trigger CI

* ".git/.scripts/commands/fmt/fmt.sh"

* Apply suggestions from code review

Co-authored-by: Koute <koute@users.noreply.github.com>

* Review comments

* Review comments

* Apply suggestions from code review

Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>

* fmt

* Bump trie-db again

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
Co-authored-by: Koute <koute@users.noreply.github.com>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This commit is contained in:
Sebastian Kunert
2023-06-28 14:57:41 +02:00
committed by GitHub
parent 943697fa69
commit 30a7e6788c
5 changed files with 185 additions and 95 deletions
+1 -1
View File
@@ -529,7 +529,7 @@ impl<'a, H: Hasher> TrieCache<'a, H> {
/// `storage_root` is the new storage root that was obtained after finishing all operations
/// using the [`TrieDBMut`](trie_db::TrieDBMut).
pub fn merge_into(self, local: &LocalTrieCache<H>, storage_root: H::Out) {
let cache = if let ValueCache::Fresh(cache) = self.value_cache { cache } else { return };
let ValueCache::Fresh(cache) = self.value_cache else { return };
if !cache.is_empty() {
let mut value_cache = local.value_cache.lock();