Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check storage in get_blobs #2609

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions linera-core/src/chain_worker/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,20 +345,29 @@ where
}

/// Returns the blobs requested by their `blob_ids` that are either in pending in the
/// chain or in the `recent_blobs` cache.
/// chain, in the `recent_blobs` cache or in storage.
async fn get_blobs(&self, blob_ids: HashSet<BlobId>) -> Result<Vec<Blob>, WorkerError> {
let pending_blobs = &self.chain.manager.get().pending_blobs;
let (found_blobs, not_found_blobs): (HashMap<BlobId, Blob>, HashSet<BlobId>) =
self.recent_blobs.try_get_many(blob_ids).await;

let mut blobs = found_blobs.into_values().collect::<Vec<_>>();
let mut missing_blobs = Vec::new();
for blob_id in not_found_blobs {
if let Some(blob) = pending_blobs.get(&blob_id) {
blobs.push(blob.clone());
} else if let Ok(blob) = self.storage.read_blob(blob_id).await {
blobs.push(blob);
} else {
missing_blobs.push(blob_id);
}
}

Ok(blobs)
if missing_blobs.is_empty() {
Ok(blobs)
} else {
Err(WorkerError::BlobsNotFound(missing_blobs))
}
}

/// Inserts a [`Blob`] into the worker's cache.
Expand Down
Loading