Skip to content

Commit fd8bae5

Browse files
starknet_patricia_storage: implement clone for cached storage
1 parent 5e1127c commit fd8bae5

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
@@ -231,7 +231,25 @@ impl<S: Storage> Storage for CachedStorage<S> {
231231
}
232232

233233
fn get_async_self(&self) -> Option<impl AsyncStorage> {
234-
// Need a concrete Option type.
235-
None::<NullStorage>
234+
let underlying_storage = self.storage.get_async_self()?;
235+
Some(CachedStorage {
236+
storage: underlying_storage,
237+
cache: self.cache.clone(), // This clone is cheap.
238+
cache_on_write: self.cache_on_write,
239+
writes: self.writes,
240+
include_inner_stats: self.include_inner_stats,
241+
})
242+
}
243+
}
244+
245+
impl<S: AsyncStorage> Clone for CachedStorage<S> {
246+
fn clone(&self) -> Self {
247+
Self {
248+
storage: self.storage.clone(),
249+
cache: self.cache.clone(), // This clone is cheap.
250+
cache_on_write: self.cache_on_write,
251+
writes: self.writes,
252+
include_inner_stats: self.include_inner_stats,
253+
}
236254
}
237255
}

0 commit comments

Comments
 (0)