Update get blobs endpoint to return a list of BlobSidecars (#4109)

* Update get blobs endpoint to return BlobSidecarList

* Update code comment

* Update blob retrieval to return BlobSidecarList without Arc

* Remove usage of BlobSidecarList type alias to avoid code conflicts

* Add clippy allow exception
This commit is contained in:
Jimmy Chen
2023-03-22 01:56:32 +11:00
committed by GitHub
parent 78414333a2
commit b40dceaae9
4 changed files with 77 additions and 55 deletions

View File

@@ -658,15 +658,13 @@ impl BeaconNodeHttpClient {
Ok(path)
}
/// Path for `lighthouse/beacon/blobs_sidecars/{block_id}`
pub fn get_blobs_sidecar_path(&self, block_id: BlockId) -> Result<Url, Error> {
let mut path = self.server.full.clone();
/// Path for `v1/beacon/blobs/{block_id}`
pub fn get_blobs_path(&self, block_id: BlockId) -> Result<Url, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("lighthouse")
.push("beacon")
.push("blobs_sidecars")
.push("blobs")
.push(&block_id.to_string());
Ok(path)
}
@@ -698,14 +696,14 @@ impl BeaconNodeHttpClient {
Ok(Some(response.json().await?))
}
/// `GET lighthouse/beacon/blobs_sidecars/{block_id}`
/// `GET v1/beacon/blobs/{block_id}`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_blobs_sidecar<T: EthSpec>(
pub async fn get_blobs<T: EthSpec>(
&self,
block_id: BlockId,
) -> Result<Option<GenericResponse<BlobsSidecar<T>>>, Error> {
let path = self.get_blobs_sidecar_path(block_id)?;
) -> Result<Option<GenericResponse<BlobSidecarList<T>>>, Error> {
let path = self.get_blobs_path(block_id)?;
let response = match self.get_response(path, |b| b).await.optional()? {
Some(res) => res,
None => return Ok(None),