@@ -91,7 +91,7 @@ use tracing::{error, info, instrument, trace, warn};
9191pub use utils:: is_valid_for_sending;
9292
9393const DEFAULT_TIPSET_CACHE_SIZE : NonZeroUsize = nonzero ! ( 1024usize ) ;
94- const EVENTS_AMT_BITWIDTH : u32 = 5 ;
94+ pub const EVENTS_AMT_BITWIDTH : u32 = 5 ;
9595
9696/// Intermediary for retrieving state objects and updating actor states.
9797type CidPair = ( Cid , Cid ) ;
@@ -567,18 +567,19 @@ where
567567 key,
568568 Box :: new ( move || {
569569 Box :: pin ( async move {
570- // If the events are not in the cache, try to load them from the blockstore
571- if let Some ( events_root) = events_root
572- && let Ok ( stamped_events) =
573- StampedEvent :: get_events ( this. blockstore ( ) , & events_root)
570+ // Try to load events directly from the blockstore
571+ if let Some ( stamped_events) = events_root
572+ . as_ref ( )
573+ . and_then ( |root| StampedEvent :: get_events ( this. blockstore ( ) , root) . ok ( ) )
574+ . filter ( |events| !events. is_empty ( ) )
574575 {
575576 return Ok ( StateEvents {
576577 events : vec ! [ stamped_events] ,
577- roots : vec ! [ Some ( events_root) ] ,
578+ roots : vec ! [ events_root] ,
578579 } ) ;
579580 }
580581
581- // If the events are neither in the cache nor in the blockstore, compute them.
582+ // Fallback: compute the tipset state if events not found in the blockstore
582583 let state_out = this
583584 . compute_tipset_state ( ts, NO_CALLBACK , VMTrace :: NotTraced )
584585 . await ?;
0 commit comments