Skip to content

Commit c314dc6

Browse files
committed
Apply review comments
1 parent c77837b commit c314dc6

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

mithril-aggregator/src/certifier_service.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,10 @@ impl CertifierService for MithrilCertifierService {
226226
) -> StdResult<OpenMessage> {
227227
debug!("CertifierService::create_open_message(signed_entity_type: {signed_entity_type:?}, protocol_message: {protocol_message:?})");
228228
let current_epoch = self.current_epoch.read().await;
229-
230-
let open_message = match self
229+
let open_message = self
231230
.open_message_repository
232-
.get_open_message(signed_entity_type)
233-
.await?
234-
{
235-
Some(open_message) => open_message,
236-
None => {
237-
self.open_message_repository
238-
.create_open_message(*current_epoch, signed_entity_type, protocol_message)
239-
.await?
240-
}
241-
};
231+
.create_open_message(*current_epoch, signed_entity_type, protocol_message)
232+
.await?;
242233
info!("CertifierService::create_open_message: created open message for {signed_entity_type:?}");
243234
debug!(
244235
"CertifierService::create_open_message: created open message ID='{}'",

mithril-aggregator/src/database/provider/signed_entity.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ impl SignedEntityStorer for SignedEntityStoreAdapter {
303303
}
304304
}
305305

306+
// TODO: this StoreAdapter implementation is temporary and concerns only the snapshots for the CardanoImmutableFilesFull signed entity type
306307
#[async_trait]
307308
impl StoreAdapter for SignedEntityStoreAdapter {
308309
type Key = String;
@@ -330,7 +331,13 @@ impl StoreAdapter for SignedEntityStoreAdapter {
330331
.map_err(|e| AdapterError::GeneralError(format!("{e}")))?;
331332
let signed_entity = cursor
332333
.next()
333-
.map(|signed_entity_record| signed_entity_record.into());
334+
.filter(|record| {
335+
matches!(
336+
record.signed_entity_type,
337+
SignedEntityType::CardanoImmutableFilesFull(_)
338+
)
339+
})
340+
.map(|record| record.into());
334341

335342
Ok(signed_entity)
336343
}

mithril-aggregator/src/runtime/runner.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub trait AggregatorRunnerTrait: Sync + Send {
5555
/// Return the current beacon from the chain
5656
async fn get_beacon_from_chain(&self) -> Result<Beacon, Box<dyn StdError + Sync + Send>>;
5757

58-
/// Retrieves the ucrrent non certified open message.
58+
/// Retrieves the current non certified open message.
5959
async fn get_current_non_certified_open_message(
6060
&self,
6161
) -> Result<Option<OpenMessage>, Box<dyn StdError + Sync + Send>>;
@@ -190,11 +190,29 @@ impl AggregatorRunnerTrait for AggregatorRunner {
190190
),
191191
];
192192

193+
// to be tested:
194+
// - if MithrilStakeDistribution not exist: Create and returns one (event if a CardanoImmutableFilesFull exist)
195+
// - if MithrilStakeDistribution exist but not certified returns it (event if a CardanoImmutableFilesFull exist)
196+
// - if MithrilStakeDistribution exist but certified:
197+
// -- existing not certified CardanoImmutableFilesFull ? returns it
198+
// -- existing certified CardanoImmutableFilesFull ? returns None
199+
// -- no existing CardanoImmutableFilesFull ? Create and returns one
193200
for signed_entity_type in signed_entity_types {
194-
let protocol_message = self.compute_protocol_message(&signed_entity_type).await?;
195-
let open_message = self
196-
.create_open_message(&signed_entity_type, &protocol_message)
197-
.await?;
201+
let open_message = match self
202+
.dependencies
203+
.certifier_service
204+
.get_open_message(&signed_entity_type)
205+
.await?
206+
{
207+
Some(existing_open_message) => existing_open_message,
208+
None => {
209+
let protocol_message =
210+
self.compute_protocol_message(&signed_entity_type).await?;
211+
self.create_open_message(&signed_entity_type, &protocol_message)
212+
.await?
213+
}
214+
};
215+
198216
if !open_message.is_certified {
199217
return Ok(Some(open_message));
200218
}

mithril-aggregator/tests/create_certificate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use test_extensions::{utilities::get_test_dir, RuntimeTester};
1313
async fn create_certificate() {
1414
let protocol_parameters = ProtocolParameters {
1515
k: 5,
16-
m: 100,
16+
m: 150,
1717
phi_f: 0.95,
1818
};
1919
let configuration = Configuration {

0 commit comments

Comments
 (0)