-
Notifications
You must be signed in to change notification settings - Fork 169
BM-1714: add override IPFS gateway #1239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
BM-1714: add override IPFS gateway #1239
Conversation
crates/broker/src/lib.rs
Outdated
self.fetch_and_upload_image( | ||
"assessor", | ||
prover, | ||
image_id, | ||
override_gateway(&image_url_str), | ||
path, | ||
default_url, | ||
) | ||
.await | ||
.context("uploading assessor image")?; | ||
Ok(image_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we try URL, if fail try custom gateway, if fail try contract specified gateway. Since our custom gateway that we pay for is now a point of failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, addressed with d95ad89
let parts: Vec<&str> = url.splitn(2, "/ipfs/").collect(); | ||
if parts.len() != 2 { | ||
return url.to_string(); | ||
} | ||
|
||
let gateway_url = | ||
std::env::var("IPFS_GATEWAY_URL").unwrap_or(BOUNDLESS_IPFS_GATEWAY_URL.to_string()); | ||
let new_url = format!("{gateway_url}/ipfs/{}", parts[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let parts: Vec<&str> = url.splitn(2, "/ipfs/").collect(); | |
if parts.len() != 2 { | |
return url.to_string(); | |
} | |
let gateway_url = | |
std::env::var("IPFS_GATEWAY_URL").unwrap_or(BOUNDLESS_IPFS_GATEWAY_URL.to_string()); | |
let new_url = format!("{gateway_url}/ipfs/{}", parts[1]); | |
let Some((_, cid)) = url.split_once("/ipfs/") else { | |
return url.to_string(); | |
}; | |
let gateway_url = | |
std::env::var("IPFS_GATEWAY_URL").unwrap_or(BOUNDLESS_IPFS_GATEWAY_URL.to_string()); | |
let new_url = format!("{gateway_url}/ipfs/{cid}"); |
Completely optional pass-by suggestion to make this a bit cleaner
Overrides the IPFS gateway in a given URL. The new gateway URL is taken from the
IPFS_GATEWAY_URL
environment variable, or defaults toBOUNDLESS_IPFS_GATEWAY_URL
if the variable is not set