Skip to content

Commit 464234b

Browse files
committed
refactor: use standard IPFS gateway URLs instead of Kubo RPC
Signed-off-by: Tomás Migone <[email protected]>
1 parent 1800a22 commit 464234b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

availability-oracle/src/ipfs.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ impl IpfsImpl {
4848
}
4949
}
5050

51-
async fn call(&self, route: &'static str, arg: Cid) -> Result<reqwest::Response, IpfsError> {
51+
async fn call(&self, cid: Cid) -> Result<reqwest::Response, IpfsError> {
5252
let _permit = self.semaphore.acquire().await;
5353

54-
// URL security: We control the endpoint and the route, the `arg` is a CID.
54+
// Using standard IPFS gateway URL format
5555
let url = format!(
56-
"{}/api/v0/{}?arg={}",
56+
"{}/ipfs/{}",
5757
self.endpoint.trim_end_matches('/'),
58-
route,
59-
arg
58+
cid
6059
);
6160
self.client
6261
.get(&url)
@@ -67,10 +66,10 @@ impl IpfsImpl {
6766
.and_then(|x| x)
6867
.map_err(|e| match e.status().map(|e| e.as_u16()) {
6968
Some(GATEWAY_TIMEOUT) | Some(CLOUDFLARE_TIMEOUT) => {
70-
IpfsError::GatewayTimeout(arg, e.into())
69+
IpfsError::GatewayTimeout(cid, e.into())
7170
}
72-
_ if e.is_timeout() => IpfsError::ClientTimeout(arg, e.into()),
73-
Some(NOT_FOUND) => IpfsError::NotFound(arg, e.into()),
71+
_ if e.is_timeout() => IpfsError::ClientTimeout(cid, e.into()),
72+
Some(NOT_FOUND) => IpfsError::NotFound(cid, e.into()),
7473
_ => IpfsError::Other(e.into()),
7574
})
7675
}
@@ -97,7 +96,7 @@ impl Ipfs for IpfsImpl {
9796
) -> Result<reqwest::Response, IpfsError> {
9897
let mut last_err = None;
9998
for _ in 0..=retries {
100-
match ipfs.call("cat", cid).await {
99+
match ipfs.call(cid).await {
101100
Ok(res) => return Ok(res),
102101
Err(e) => {
103102
last_err = Some(e);

0 commit comments

Comments
 (0)