Skip to content

Commit 253a0f6

Browse files
starknet_patricia_storage: implement clone for cached storage
1 parent 76ee609 commit 253a0f6

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
@@ -298,7 +298,25 @@ impl<S: Storage> Storage for CachedStorage<S> {
298298
}
299299

300300
fn get_async_self(&self) -> Option<impl AsyncStorage> {
301-
// Need a concrete Option type.
302-
None::<NullStorage>
301+
let underlying_storage = self.storage.get_async_self()?;
302+
Some(CachedStorage {
303+
storage: underlying_storage,
304+
cache: self.cache.clone(), // This clone is cheap.
305+
cache_on_write: self.cache_on_write,
306+
writes: self.writes,
307+
include_inner_stats: self.include_inner_stats,
308+
})
309+
}
310+
}
311+
312+
impl<S: AsyncStorage> Clone for CachedStorage<S> {
313+
fn clone(&self) -> Self {
314+
Self {
315+
storage: self.storage.clone(),
316+
cache: self.cache.clone(), // This clone is cheap.
317+
cache_on_write: self.cache_on_write,
318+
writes: self.writes,
319+
include_inner_stats: self.include_inner_stats,
320+
}
303321
}
304322
}

0 commit comments

Comments
 (0)