Skip to content

Commit 50c6063

Browse files
starknet_patricia_storage: implement clone for cached storage
1 parent a72eee1 commit 50c6063

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

crates/starknet_patricia_storage/src/map_storage.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,25 @@ impl<S: Storage> Storage for CachedStorage<S> {
313313
}
314314

315315
fn get_async_self(&self) -> Option<impl AsyncStorage> {
316-
// Need a concrete Option type.
317-
None::<NullStorage>
316+
let underlying_storage = self.storage.get_async_self()?;
317+
Some(CachedStorage {
318+
storage: underlying_storage,
319+
cache: self.cache.clone(), // This clone is cheap.
320+
cache_on_write: self.cache_on_write,
321+
writes: self.writes,
322+
include_inner_stats: self.include_inner_stats,
323+
})
324+
}
325+
}
326+
327+
impl<S: AsyncStorage> Clone for CachedStorage<S> {
328+
fn clone(&self) -> Self {
329+
Self {
330+
storage: self.storage.clone(),
331+
cache: self.cache.clone(), // This clone is cheap.
332+
cache_on_write: self.cache_on_write,
333+
writes: self.writes,
334+
include_inner_stats: self.include_inner_stats,
335+
}
318336
}
319337
}

0 commit comments

Comments
 (0)