Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions availability-oracle/src/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum IpfsError {
GatewayTimeout(Cid, Error), // Gateway/Cloudflare timed-out
ClientTimeout(Cid, Error), // Client timed-out when requesting the file
NotFound(Cid, Error), // Manifest not found
Denied(Cid, Error), // Gateway refuses to serve this object (auth/denylist/removed)
Other(Error),
}

Expand Down Expand Up @@ -66,6 +67,9 @@ impl IpfsImpl {
}
_ if e.is_timeout() => IpfsError::ClientTimeout(cid, e.into()),
Some(NOT_FOUND) => IpfsError::NotFound(cid, e.into()),
Some(UNAUTHORIZED) | Some(FORBIDDEN) | Some(GONE) | Some(UNAVAILABLE_LEGAL) => {
IpfsError::Denied(cid, e.into())
}
_ => IpfsError::Other(e.into()),
})
}
Expand All @@ -74,6 +78,10 @@ impl IpfsImpl {
const CLOUDFLARE_TIMEOUT: u16 = 524;
const GATEWAY_TIMEOUT: u16 = 504;
const NOT_FOUND: u16 = 404;
const UNAUTHORIZED: u16 = 401;
const FORBIDDEN: u16 = 403;
const GONE: u16 = 410;
const UNAVAILABLE_LEGAL: u16 = 451;

#[async_trait]
impl Ipfs for IpfsImpl {
Expand Down
1 change: 1 addition & 0 deletions availability-oracle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ impl From<IpfsError> for CheckError {
CheckError::Invalid(Invalid::Unavailable(cid, err))
}
IpfsError::NotFound(cid, err) => CheckError::Invalid(Invalid::Unavailable(cid, err)),
IpfsError::Denied(cid, err) => CheckError::Invalid(Invalid::Unavailable(cid, err)),
IpfsError::Other(e) => CheckError::Other(e),
}
}
Expand Down
Loading