@@ -325,23 +325,13 @@ impl<
325325 let round = notarization. round( ) ;
326326 let commitment = notarization. proposal. payload;
327327
328- // Block on waiting for the block to be reconstructed; We cannot move forward without
329- // having the block digest.
330- while !shard_layer. has_digest( & commitment) . await {
331- dbg!( "spinning" ) ;
332- shard_layer. try_reconstruct( commitment) . await . expect( "Reconstruction error not yet handled" ) ;
333- }
334-
335- // Request the block digest for the block corresponding to the coding commitment.
336- let digest = shard_layer. get_digest( & commitment) . await . unwrap( ) ;
337-
338328 // Store notarization by view
339- self . cache. put_notarization( round, digest , notarization. clone( ) ) . await ;
329+ self . cache. put_notarization( round, commitment , notarization. clone( ) ) . await ;
340330
341331 // Search for block locally, otherwise fetch it remotely
342- if let Some ( block) = self . find_block( & mut shard_layer, digest ) . await {
332+ if let Some ( block) = self . find_block( & mut shard_layer, commitment ) . await {
343333 // If found, persist the block
344- self . cache_block( round, digest , block) . await ;
334+ self . cache_block( round, commitment , block) . await ;
345335 } else {
346336 debug!( ?round, "notarized block missing" ) ;
347337 resolver. fetch( Request :: <B >:: Notarized { round } ) . await ;
@@ -360,28 +350,18 @@ impl<
360350 let round = finalization. round( ) ;
361351 let commitment = finalization. proposal. payload;
362352
363- // Block on waiting for the block to be reconstructed; We cannot move forward without
364- // having the block digest.
365- while !shard_layer. has_digest( & commitment) . await {
366- dbg!( "spinning" ) ;
367- shard_layer. try_reconstruct( commitment) . await . expect( "Reconstruction error not yet handled" ) ;
368- }
369-
370- // Request the block digest for the block corresponding to the coding commitment.
371- let digest = shard_layer. get_digest( & commitment) . await . unwrap( ) ;
372-
373- self . cache. put_finalization( round, digest, finalization. clone( ) ) . await ;
353+ self . cache. put_finalization( round, commitment, finalization. clone( ) ) . await ;
374354
375355 // Search for block locally, otherwise fetch it remotely
376- if let Some ( block) = self . find_block( & mut shard_layer, digest ) . await {
356+ if let Some ( block) = self . find_block( & mut shard_layer, commitment ) . await {
377357 // If found, persist the block
378358 let height = block. height( ) ;
379- self . finalize( height, digest , block, Some ( finalization) , & mut notifier_tx) . await ;
359+ self . finalize( height, commitment , block, Some ( finalization) , & mut notifier_tx) . await ;
380360 debug!( ?round, height, "finalized block stored" ) ;
381361 } else {
382362 // Otherwise, fetch the block from the network.
383- debug!( ?round, ?digest , "finalized block missing" ) ;
384- resolver. fetch( Request :: <B >:: Block ( digest ) ) . await ;
363+ debug!( ?round, ?commitment , "finalized block missing" ) ;
364+ resolver. fetch( Request :: <B >:: Block ( commitment ) ) . await ;
385365 }
386366 }
387367 Message :: Get { commitment, response } => {
@@ -492,6 +472,11 @@ impl<
492472 // Iterate backwards, repairing blocks as we go.
493473 while cursor. height( ) > height {
494474 let commitment = cursor. parent( ) ;
475+ let Some ( commitment) = shard_layer. get_digest( & commitment) . await else {
476+ dbg!( "Missing block digest" ) ;
477+ break ;
478+ } ;
479+
495480 if let Some ( block) = self . find_block( & mut shard_layer, commitment) . await {
496481 let finalization = self . cache. get_finalization_for( commitment) . await ;
497482 self . finalize( block. height( ) , commitment, block. clone( ) , finalization, & mut notifier_tx) . await ;
@@ -559,15 +544,7 @@ impl<
559544
560545 // Get block
561546 let commitment = notarization. proposal. payload;
562- let digest = match shard_layer. get_digest( & commitment) . await {
563- Some ( digest) => digest,
564- None => {
565- debug!( ?commitment, "notarized block missing commitment mapping on request" ) ;
566- continue ;
567- }
568- } ;
569-
570- let Some ( block) = self . find_block( & mut shard_layer, digest) . await else {
547+ let Some ( block) = self . find_block( & mut shard_layer, commitment) . await else {
571548 debug!( ?commitment, "block missing on request" ) ;
572549 continue ;
573550 } ;
@@ -760,7 +737,7 @@ impl<
760737 ) -> Option < B > {
761738 // Check shard layer.
762739 if let Some ( block) = shards
763- . block_by_digest ( commitment)
740+ . try_reconstruct ( commitment)
764741 . await
765742 . expect ( "reconstruction error not yet handled" )
766743 {
0 commit comments