diff --git a/availability-oracle/src/ipfs.rs b/availability-oracle/src/ipfs.rs index 508b32c..ee17ec4 100644 --- a/availability-oracle/src/ipfs.rs +++ b/availability-oracle/src/ipfs.rs @@ -48,16 +48,11 @@ impl IpfsImpl { } } - async fn call(&self, route: &'static str, arg: Cid) -> Result { + async fn call(&self, cid: Cid) -> Result { let _permit = self.semaphore.acquire().await; - // URL security: We control the endpoint and the route, the `arg` is a CID. - let url = format!( - "{}/api/v0/{}?arg={}", - self.endpoint.trim_end_matches('/'), - route, - arg - ); + // Using standard IPFS gateway URL format + let url = format!("{}/ipfs/{}", self.endpoint.trim_end_matches('/'), cid); self.client .get(&url) .timeout(self.timeout) @@ -67,10 +62,10 @@ impl IpfsImpl { .and_then(|x| x) .map_err(|e| match e.status().map(|e| e.as_u16()) { Some(GATEWAY_TIMEOUT) | Some(CLOUDFLARE_TIMEOUT) => { - IpfsError::GatewayTimeout(arg, e.into()) + IpfsError::GatewayTimeout(cid, e.into()) } - _ if e.is_timeout() => IpfsError::ClientTimeout(arg, e.into()), - Some(NOT_FOUND) => IpfsError::NotFound(arg, e.into()), + _ if e.is_timeout() => IpfsError::ClientTimeout(cid, e.into()), + Some(NOT_FOUND) => IpfsError::NotFound(cid, e.into()), _ => IpfsError::Other(e.into()), }) } @@ -97,7 +92,7 @@ impl Ipfs for IpfsImpl { ) -> Result { let mut last_err = None; for _ in 0..=retries { - match ipfs.call("cat", cid).await { + match ipfs.call(cid).await { Ok(res) => return Ok(res), Err(e) => { last_err = Some(e);