Skip to content

Commit 5123476

Browse files
committed
chore: DRY
1 parent 766a28d commit 5123476

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

crates/blobber/src/blobs/fetch.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ where
212212
///
213213
/// This method returns whatever blobs the consensus client provides, even
214214
/// if fewer than requested. Use this when partial blob results are acceptable.
215+
///
216+
/// We assume the CL will NEVER return unrelated blobs, only correct ones.
215217
#[instrument(skip_all)]
216218
#[allow(dead_code)]
217219
async fn get_blobs_from_cl(
@@ -243,33 +245,22 @@ where
243245
/// This method enforces that the consensus client returns exactly the
244246
/// number of blobs requested. If the count doesn't match, returns
245247
/// [`FetchError::BlobCountMismatch`].
248+
///
249+
/// We assume the CL will NEVER return unrelated blobs, only correct ones.
246250
#[instrument(skip_all)]
247251
async fn get_blobs_from_cl_exact(
248252
&self,
249253
slot: usize,
250254
versioned_hashes: &[B256],
251255
) -> FetchResult<Blobs> {
252-
let Some(url) = &self.cl_url else {
253-
return Err(FetchError::ConsensusClientUrlNotSet);
254-
};
255-
256-
let mut url =
257-
url.join(&format!("/eth/v1/beacon/blobs/{slot}")).map_err(FetchError::UrlParse)?;
258-
259256
let expected = versioned_hashes.len();
260-
let versioned_hashes =
261-
versioned_hashes.iter().map(|hash| hash.to_string()).collect::<Vec<_>>().join(",");
262-
url.query_pairs_mut().append_pair("versioned_hashes", &versioned_hashes);
263-
264-
let response = self.client.get(url).header("accept", "application/json").send().await?;
257+
let blobs = self.get_blobs_from_cl(slot, versioned_hashes).await?;
265258

266-
let response: GetBlobsResponse = response.json().await?;
267-
268-
if response.data.len() != expected {
269-
return Err(FetchError::BlobCountMismatch { expected, actual: response.data.len() });
259+
if blobs.len() != expected {
260+
return Err(FetchError::BlobCountMismatch { expected, actual: blobs.len() });
270261
}
271262

272-
Ok(Arc::new(response.data).into())
263+
Ok(blobs)
273264
}
274265
}
275266

0 commit comments

Comments
 (0)