Skip to content

Commit adcd369

Browse files
committed
fix: cargo fmt
1 parent 1149cae commit adcd369

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

aggregation_mode/src/backend/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pub mod config;
22
pub mod fetcher;
33
mod merkle_tree;
4+
mod retry;
45
mod s3;
56
mod types;
6-
mod retry;
77

88
use crate::aggregators::{AlignedProof, ProofAggregationError, ZKVMEngine};
99

aggregation_mode/src/backend/retry.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<E: std::fmt::Display> std::error::Error for RetryError<E> where E: std::fmt
3030

3131
/// Supports retries only on async functions. See: https://docs.rs/backon/latest/backon/#retry-an-async-function
3232
/// Runs with `jitter: false`.
33-
///
33+
///
3434
/// # Parameters
3535
/// * `function` - The async function to retry
3636
/// * `min_delay_millis` - Initial delay before first retry attempt (in milliseconds)
@@ -44,9 +44,9 @@ pub async fn retry_function<FutureFn, Fut, T, E>(
4444
max_times: usize,
4545
max_delay_seconds: u64,
4646
) -> Result<T, RetryError<E>>
47-
where
48-
Fut: Future<Output = Result<T, RetryError<E>>>,
49-
FutureFn: FnMut() -> Fut,
47+
where
48+
Fut: Future<Output = Result<T, RetryError<E>>>,
49+
FutureFn: FnMut() -> Fut,
5050
{
5151
let backoff = ExponentialBuilder::default()
5252
.with_min_delay(Duration::from_millis(min_delay_millis))

aggregation_mode/src/backend/s3.rs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use std::time::Duration;
1+
use crate::backend::retry::{retry_function, RetryError};
22
use aligned_sdk::common::types::VerificationData;
3+
use std::time::Duration;
34
use tracing::{info, warn};
4-
use crate::backend::retry::{retry_function, RetryError};
55

66
#[derive(Debug)]
77
#[allow(dead_code)]
@@ -40,20 +40,22 @@ async fn get_aligned_batch_from_s3_retryable(
4040
.connect_timeout(CONNECT_TIMEOUT_SECONDS)
4141
.timeout(BATCH_DOWNLOAD_TIMEOUT_SECONDS)
4242
.build()
43-
.map_err(|e| RetryError::Permanent(GetBatchProofsError::ReqwestClientFailed(e.to_string())))?;
44-
45-
let response = client
46-
.get(&url)
47-
.send()
48-
.await
4943
.map_err(|e| {
50-
warn!("Failed to send request to {}: {}", url, e);
51-
RetryError::Transient(GetBatchProofsError::FetchingS3Batch(e.to_string()))
44+
RetryError::Permanent(GetBatchProofsError::ReqwestClientFailed(e.to_string()))
5245
})?;
5346

47+
let response = client.get(&url).send().await.map_err(|e| {
48+
warn!("Failed to send request to {}: {}", url, e);
49+
RetryError::Transient(GetBatchProofsError::FetchingS3Batch(e.to_string()))
50+
})?;
51+
5452
if !response.status().is_success() {
5553
let status_code = response.status().as_u16();
56-
let reason = response.status().canonical_reason().unwrap_or("").to_string();
54+
let reason = response
55+
.status()
56+
.canonical_reason()
57+
.unwrap_or("")
58+
.to_string();
5759

5860
// Determine if the error is retryable based on status code
5961
let error = GetBatchProofsError::StatusFailed((status_code, reason));
@@ -69,20 +71,16 @@ async fn get_aligned_batch_from_s3_retryable(
6971
};
7072
}
7173

72-
let bytes = response
73-
.bytes()
74-
.await
75-
.map_err(|e| {
76-
warn!("Failed to read response body from {}: {}", url, e);
77-
RetryError::Transient(GetBatchProofsError::EmptyBody(e.to_string()))
78-
})?;
74+
let bytes = response.bytes().await.map_err(|e| {
75+
warn!("Failed to read response body from {}: {}", url, e);
76+
RetryError::Transient(GetBatchProofsError::EmptyBody(e.to_string()))
77+
})?;
7978
let bytes: &[u8] = bytes.iter().as_slice();
8079

81-
let data: Vec<VerificationData> = ciborium::from_reader(bytes)
82-
.map_err(|e| {
83-
warn!("Failed to deserialize batch data from {}: {}", url, e);
84-
RetryError::Permanent(GetBatchProofsError::Deserialization(e.to_string()))
85-
})?;
80+
let data: Vec<VerificationData> = ciborium::from_reader(bytes).map_err(|e| {
81+
warn!("Failed to deserialize batch data from {}: {}", url, e);
82+
RetryError::Permanent(GetBatchProofsError::Deserialization(e.to_string()))
83+
})?;
8684

8785
Ok(data)
8886
}

0 commit comments

Comments
 (0)