Skip to content

Commit 852df5b

Browse files
committed
feat(aggregator): add a 'SignatureProcessor' trait
1 parent d0b51b7 commit 852df5b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

mithril-aggregator/src/services/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ mod epoch_service;
1616
mod message;
1717
mod prover;
1818
mod signable_builder;
19+
mod signature_consumer;
20+
mod signature_processor;
1921
mod signed_entity;
2022
mod signer_registration;
2123
mod snapshotter;
@@ -30,6 +32,8 @@ pub use epoch_service::*;
3032
pub use message::*;
3133
pub use prover::*;
3234
pub use signable_builder::*;
35+
pub use signature_consumer::*;
36+
pub use signature_processor::*;
3337
pub use signed_entity::*;
3438
pub use signer_registration::*;
3539
pub use snapshotter::*;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use mithril_common::StdResult;
2+
3+
/// A signature processor which receives signature and processes them.
4+
#[cfg_attr(test, mockall::automock)]
5+
#[async_trait::async_trait]
6+
pub trait SignatureProcessor: Sync + Send {
7+
/// Processes the signatures received from the consumer.
8+
async fn process_signatures(&self) -> StdResult<()>;
9+
10+
/// Starts the processor, which will run indefinitely, processing signatures as they arrive.
11+
async fn run(&self) -> StdResult<()> {
12+
loop {
13+
self.process_signatures().await?;
14+
}
15+
}
16+
17+
/// Stops the processor. This method should be called to gracefully shut down the processor.
18+
async fn stop(&self) -> StdResult<()>;
19+
}

0 commit comments

Comments
 (0)