Skip to content

Commit d1ea024

Browse files
committed
feat(aggregator): add delay on error in signature processor
1 parent 7729d9a commit d1ea024

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

mithril-aggregator/src/services/signature_processor.rs

Lines changed: 13 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, 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>,
@@ -100,7 +102,16 @@ impl SignatureProcessor for SequentialSignatureProcessor {
100102

101103
return Ok(());
102104
}
103-
_ = self.process_signatures() => {}
105+
res = self.process_signatures() => {
106+
match res {
107+
Err(e) => {
108+
error!(self.logger, "Error processing signatures"; "error" => ?e);
109+
error!(self.logger, "Sleep for {} seconds", Self::ERROR_DELAY_IN_SECONDS.as_secs());
110+
tokio::time::sleep(Self::ERROR_DELAY_IN_SECONDS).await;
111+
}
112+
_ => {}
113+
}
114+
}
104115
}
105116
}
106117
}

0 commit comments

Comments
 (0)