Skip to content

Commit e39bb60

Browse files
starknet_particia_storage: extend the storage trait to optionally flush to cache
1 parent 0517529 commit e39bb60

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
@@ -330,6 +330,11 @@ impl<S: Storage> Storage for CachedStorage<S> {
330330
include_inner_stats: self.include_inner_stats,
331331
})
332332
}
333+
334+
fn flush_to_cache(&mut self, map: DbHashMap) -> PatriciaStorageResult<()> {
335+
Self::flush_to_cache(self, map);
336+
Ok(())
337+
}
333338
}
334339

335340
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)