Skip to content

Commit 7fe9ac6

Browse files
committed
fix: wrap update slot request in a retryer + log any error
1 parent b0cf5c3 commit 7fe9ac6

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/main.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use anyhow::Result;
1+
use anyhow::{anyhow, Context as AnyhowContext, Result};
2+
use backoff::{future::retry_notify, Error as BackoffError};
23
use context::{Config as ContextConfig, Context};
34
use env::Environment;
45
use slots_processor::{Config as SlotsProcessorConfig, SlotsProcessor};
5-
use tracing::{info, Instrument};
6+
use tracing::{error, info, warn, Instrument};
7+
use utils::exp_backoff::get_exp_backoff_config;
68

79
use crate::utils::telemetry::{get_subscriber, init_subscriber};
810

@@ -81,10 +83,27 @@ async fn main() -> Result<()> {
8183
.instrument(slot_manager_span)
8284
.await?;
8385

84-
blobscan_client.update_slot(chunk_final_slot - 1).await?;
86+
match retry_notify(
87+
get_exp_backoff_config(),
88+
|| async move {
89+
blobscan_client
90+
.update_slot(chunk_final_slot - 1)
91+
.await.map_err(|err| err.into())
92+
},
93+
|e, duration: Duration| {
94+
let duration = duration.as_secs();
95+
warn!("Failed to update latest slot to {}. Retrying in {duration} seconds… (Reason: {e})", chunk_final_slot - 1);
96+
},
97+
).await {
98+
Ok(_) => (),
99+
Err(err) => {
100+
error!("Failed to update latest slot to {}", chunk_final_slot - 1);
101+
return Err(err.into());
102+
}
103+
};
85104

86105
info!(
87-
"Chunk {} of {} ({} slots) processed successfully!. Updating latest slot to {}.",
106+
"Chunk {} of {} ({} slots) processed successfully!. Latest slot updated to {}.",
88107
i+1,
89108
num_chunks,
90109
chunk_final_slot - chunk_initial_slot,

0 commit comments

Comments
 (0)