We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 569a743 + e8491d5 commit 97459baCopy full SHA for 97459ba
availability-oracle/src/ipfs.rs
@@ -86,7 +86,24 @@ impl Ipfs for IpfsImpl {
86
return Result::Ok(cached_bytes);
87
}
88
89
- let res = self.call("cat", cid).await;
+ async fn call_with_retry(
90
+ ipfs: &IpfsImpl,
91
+ cid: Cid,
92
+ retries: usize,
93
+ ) -> Result<reqwest::Response, IpfsError> {
94
+ let mut last_err = None;
95
+ for _ in 0..=retries {
96
+ match ipfs.call("cat", cid).await {
97
+ Ok(res) => return Ok(res),
98
+ Err(e) => {
99
+ last_err = Some(e);
100
+ }
101
102
103
+ Err(last_err.unwrap())
104
105
+
106
+ let res = call_with_retry(self, cid, 1).await;
107
METRICS.ipfs_requests_total.inc();
108
let final_bytes = res?.bytes().map_err(|e| IpfsError::Other(e.into())).await?;
109
0 commit comments