diff --git a/linera-core/src/chain_worker/state/attempted_changes.rs b/linera-core/src/chain_worker/state/attempted_changes.rs index a4f9c6e5fd3..91bd96a50bf 100644 --- a/linera-core/src/chain_worker/state/attempted_changes.rs +++ b/linera-core/src/chain_worker/state/attempted_changes.rs @@ -206,8 +206,7 @@ where let required_blob_ids = executed_block.required_blob_ids(); // Verify that no unrelated blobs were provided. self.state - .check_for_unneeded_blobs(&required_blob_ids, blobs) - .await?; + .check_for_unneeded_blobs(&required_blob_ids, blobs)?; let remaining_required_blob_ids = required_blob_ids .difference(&blobs.iter().map(|blob| blob.id()).collect()) .cloned() @@ -300,13 +299,15 @@ where let required_blob_ids = executed_block.required_blob_ids(); // Verify that no unrelated blobs were provided. self.state - .check_for_unneeded_blobs(&required_blob_ids, blobs) - .await?; + .check_for_unneeded_blobs(&required_blob_ids, blobs)?; let remaining_required_blob_ids = required_blob_ids .difference(&blobs.iter().map(|blob| blob.id()).collect()) .cloned() .collect(); - let mut blobs_in_block = self.state.get_blobs(&remaining_required_blob_ids).await?; + let mut blobs_in_block = self + .state + .get_blobs_and_checks_storage(&remaining_required_blob_ids) + .await?; blobs_in_block.extend_from_slice(blobs); let certificate_hash = certificate.hash(); diff --git a/linera-core/src/chain_worker/state/mod.rs b/linera-core/src/chain_worker/state/mod.rs index 9d2bf1e72ae..48cf016a52d 100644 --- a/linera-core/src/chain_worker/state/mod.rs +++ b/linera-core/src/chain_worker/state/mod.rs @@ -330,7 +330,7 @@ where } /// Returns an error if unrelated blobs were provided. - async fn check_for_unneeded_blobs( + fn check_for_unneeded_blobs( &self, required_blob_ids: &HashSet, blobs: &[Blob], @@ -347,9 +347,12 @@ where Ok(()) } - /// Returns the blobs requested by their `blob_ids` that are either in the chain manager's - /// pending blobs or in storage. - async fn get_blobs(&self, blob_ids: &HashSet) -> Result, WorkerError> { + /// Returns the blobs requested by their `blob_ids` that are in the chain manager's pending blobs + /// and checks that they are otherwise in storage. + async fn get_blobs_and_checks_storage( + &self, + blob_ids: &HashSet, + ) -> Result, WorkerError> { let pending_blobs = &self.chain.manager.get().pending_blobs; let mut found_blobs = Vec::new(); @@ -361,14 +364,7 @@ where missing_blob_ids.push(*blob_id); } } - let blobs = self.storage.read_blobs(&missing_blob_ids).await?; - let mut not_found_blob_ids = Vec::new(); - for (blob, blob_id) in blobs.into_iter().zip(missing_blob_ids) { - match blob { - None => not_found_blob_ids.push(blob_id), - Some(blob) => found_blobs.push(blob), - } - } + let not_found_blob_ids = self.storage.missing_blobs(&missing_blob_ids).await?; if not_found_blob_ids.is_empty() { Ok(found_blobs) diff --git a/linera-core/src/chain_worker/state/temporary_changes.rs b/linera-core/src/chain_worker/state/temporary_changes.rs index 1d4931d9080..342239b6bef 100644 --- a/linera-core/src/chain_worker/state/temporary_changes.rs +++ b/linera-core/src/chain_worker/state/temporary_changes.rs @@ -41,7 +41,7 @@ impl<'state, StorageClient> ChainWorkerStateWithTemporaryChanges<'state, Storage where StorageClient: Storage + Clone + Send + Sync + 'static, { - /// Creates a new [`ChainWorkerStateWithAttemptedChanges`] instance to temporarily change the + /// Creates a new [`ChainWorkerStateWithTemporaryChanges`] instance to temporarily change the /// `state`. pub(super) async fn new(state: &'state mut ChainWorkerState) -> Self { assert!( @@ -207,8 +207,7 @@ where // Verify that no unrelated blobs were provided. let published_blob_ids = block.published_blob_ids(); self.0 - .check_for_unneeded_blobs(&published_blob_ids, blobs) - .await?; + .check_for_unneeded_blobs(&published_blob_ids, blobs)?; let missing_published_blob_ids = published_blob_ids .difference(&blobs.iter().map(|blob| blob.id()).collect()) .cloned()