@@ -115,19 +115,13 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
115115 cx : & SyncNetworkContext < T > ,
116116 ) -> Result < ( ) , LookupRequestError > {
117117 let block_already_downloaded = self . block_already_downloaded ( ) ;
118- let should_request_blobs = if self . blob_request_state . requested_ids . is_empty ( ) {
119- let blob_ids = self . missing_blob_ids ( ) ;
120- self . blob_request_state . requested_ids = blob_ids;
121- !self . blob_request_state . requested_ids . is_empty ( )
122- } else {
123- false
124- } ;
118+ let blobs_already_downloaded = self . blobs_already_downloaded ( ) ;
125119
126120 if !block_already_downloaded {
127121 self . block_request_state
128122 . build_request_and_send ( self . id , cx) ?;
129123 }
130- if should_request_blobs {
124+ if !blobs_already_downloaded {
131125 self . blob_request_state
132126 . build_request_and_send ( self . id , cx) ?;
133127 }
@@ -259,6 +253,21 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
259253 }
260254 }
261255
256+ /// Updates the `requested_ids` field of the `BlockRequestState` with the most recent picture
257+ /// of which blobs still need to be requested. Returns `true` if there are no more blobs to
258+ /// request.
259+ pub ( crate ) fn blobs_already_downloaded ( & mut self ) -> bool {
260+ if matches ! ( self . blob_request_state. state. state, State :: AwaitingDownload ) {
261+ self . update_blobs_request ( ) ;
262+ }
263+ self . blob_request_state . requested_ids . is_empty ( )
264+ }
265+
266+ /// Updates this request with the most recent picture of which blobs still need to be requested.
267+ pub fn update_blobs_request ( & mut self ) {
268+ self . blob_request_state . requested_ids = self . missing_blob_ids ( ) ;
269+ }
270+
262271 /// If `child_components` is `Some`, we know block components won't hit the data
263272 /// availability cache, so we don't check its processing cache unless `child_components`
264273 /// is `None`.
0 commit comments