Skip to content

Commit 63b6032

Browse files
starknet_particia_storage: extend the storage trait to optionally flush to cache
1 parent b1c945d commit 63b6032

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

crates/starknet_patricia_storage/src/map_storage.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ impl<S: Storage> Storage for CachedStorage<S> {
314314
include_inner_stats: self.include_inner_stats,
315315
})
316316
}
317+
318+
fn flush_to_cache(&mut self, map: DbHashMap) -> PatriciaStorageResult<()> {
319+
Self::flush_to_cache(self, map);
320+
Ok(())
321+
}
317322
}
318323

319324
impl<S: AsyncStorage> Clone for CachedStorage<S> {

crates/starknet_patricia_storage/src/storage_trait.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ pub trait Storage: Send + Sync {
155155

156156
/// If the storage is async, returns an instance of the async storage.
157157
fn get_async_self(&self) -> Option<impl AsyncStorage>;
158+
159+
/// If uses a cache, flushes the given map into the cache.
160+
fn flush_to_cache(&mut self, _map: DbHashMap) -> PatriciaStorageResult<()> {
161+
Ok(())
162+
}
158163
}
159164

160165
/// A trait wrapper for [Storage] that supports concurrency.

0 commit comments

Comments
 (0)