mithril_aggregator/dependency_injection/builder/protocol/
proving.rs1use std::sync::Arc;
2
3use mithril_common::crypto_helper::MKTreeStoreInMemory;
4
5use crate::dependency_injection::{DependenciesBuilder, Result};
6use crate::services::{MithrilProverService, ProverService};
7
8impl DependenciesBuilder {
9 pub async fn build_prover_service(&mut self) -> Result<Arc<dyn ProverService>> {
11 let mk_map_pool_size = self
12 .configuration
13 .cardano_transactions_prover_cache_pool_size;
14 let transaction_retriever = self.get_transaction_repository().await?;
15 let block_range_root_retriever = self.get_transaction_repository().await?;
16 let logger = self.root_logger();
17 let prover_service = MithrilProverService::<MKTreeStoreInMemory>::new(
18 transaction_retriever,
19 block_range_root_retriever,
20 mk_map_pool_size,
21 logger,
22 );
23
24 Ok(Arc::new(prover_service))
25 }
26
27 pub async fn get_prover_service(&mut self) -> Result<Arc<dyn ProverService>> {
29 if self.prover_service.is_none() {
30 self.prover_service = Some(self.build_prover_service().await?);
31 }
32
33 Ok(self.prover_service.as_ref().cloned().unwrap())
34 }
35}