@@ -307,32 +307,30 @@ impl sui_types::storage::ObjectStore for ReplayStore<'_> {
307307 // at the checkpoint (mimic latest runtime behavior)
308308 fn get_object ( & self , object_id : & ObjectID ) -> Option < Object > {
309309 trace ! ( "get_object({})" , object_id) ;
310-
311- match self . object_cache . borrow ( ) . get ( object_id) {
312- Some ( versions) => versions. last_key_value ( ) . map ( |( _version, obj) | obj. clone ( ) ) ,
313- None => {
314- let fetched_object = self
315- . store
316- . get_objects ( & [ ObjectKey {
317- object_id : * object_id,
318- version_query : VersionQuery :: AtCheckpoint ( self . checkpoint ) ,
319- } ] )
320- . map_err ( |e| SuiErrorKind :: Storage ( e. to_string ( ) ) )
321- . ok ( ) ?
322- . into_iter ( )
323- . next ( ) ?
324- . map ( |( obj, _version) | obj) ?;
325-
326- // Add the fetched object to the cache
327- let mut cache = self . object_cache . borrow_mut ( ) ;
328- cache
329- . entry ( * object_id)
330- . or_default ( )
331- . insert ( fetched_object. version ( ) . value ( ) , fetched_object. clone ( ) ) ;
332-
333- Some ( fetched_object)
334- }
310+ if let Some ( cache) = self . object_cache . borrow ( ) . get ( object_id) {
311+ return cache. last_key_value ( ) . map ( |( _version, obj) | obj. clone ( ) ) ;
335312 }
313+
314+ let fetched_object = self
315+ . store
316+ . get_objects ( & [ ObjectKey {
317+ object_id : * object_id,
318+ version_query : VersionQuery :: AtCheckpoint ( self . checkpoint ) ,
319+ } ] )
320+ . map_err ( |e| SuiErrorKind :: Storage ( e. to_string ( ) ) )
321+ . ok ( ) ?
322+ . into_iter ( )
323+ . next ( ) ?
324+ . map ( |( obj, _version) | obj) ?;
325+
326+ // Add the fetched object to the cache
327+ let mut cache = self . object_cache . borrow_mut ( ) ;
328+ cache
329+ . entry ( * object_id)
330+ . or_default ( )
331+ . insert ( fetched_object. version ( ) . value ( ) , fetched_object. clone ( ) ) ;
332+
333+ Some ( fetched_object)
336334 }
337335
338336 // Get an object by its ID and version
0 commit comments