Skip to content

Commit fc30a7c

Browse files
committed
feat(aggregator): add delay on error in signature processor
1 parent 8d0f6c0 commit fc30a7c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mithril-aggregator/src/services/signature_processor.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
use std::{sync::Arc, time::Duration};
22

33
use slog::{Logger, error, trace, warn};
44

@@ -34,6 +34,8 @@ pub struct SequentialSignatureProcessor {
3434
}
3535

3636
impl SequentialSignatureProcessor {
37+
const ERROR_DELAY_IN_SECONDS: Duration = Duration::from_secs(1);
38+
3739
/// Creates a new `SignatureProcessor` instance.
3840
pub fn new(
3941
consumer: Arc<dyn SignatureConsumer>,
@@ -111,7 +113,13 @@ impl SignatureProcessor for SequentialSignatureProcessor {
111113

112114
return Ok(());
113115
}
114-
_ = self.process_signatures() => {}
116+
res = self.process_signatures() => {
117+
if let Err(e) = res {
118+
error!(self.logger, "Error processing signatures"; "error" => ?e);
119+
error!(self.logger, "Sleep for {} seconds", Self::ERROR_DELAY_IN_SECONDS.as_secs());
120+
tokio::time::sleep(Self::ERROR_DELAY_IN_SECONDS).await;
121+
}
122+
}
115123
}
116124
}
117125
}

0 commit comments

Comments
 (0)