Skip to content

Commit 77c4ffe

Browse files
committed
better fix
1 parent 4acc294 commit 77c4ffe

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,6 @@ impl MissingBlobs {
655655
MissingBlobs::BlobsNotRequired => vec![],
656656
}
657657
}
658-
659-
pub fn clear(&mut self) {
660-
match self {
661-
MissingBlobs::KnownMissing(ref mut v) => v.clear(),
662-
MissingBlobs::PossibleMissing(ref mut v) => v.clear(),
663-
MissingBlobs::BlobsNotRequired => (),
664-
}
665-
}
666658
}
667659

668660
impl Into<Vec<BlobIdentifier>> for MissingBlobs {

beacon_node/network/src/sync/block_lookups/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,6 @@ impl<L: Lookup, T: BeaconChainTypes> RequestState<L, T> for BlobRequestState<L,
396396
None => {
397397
self.state.state = State::Processing { peer_id };
398398
let blobs = std::mem::take(&mut self.blob_download_queue);
399-
self.requested_ids.clear();
400-
401399
Ok(Some(blobs))
402400
}
403401
}

beacon_node/network/src/sync/block_lookups/single_block_lookup.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)