Skip to content

Commit dca5fc6

Browse files
committed
refactor: get_current_non_certified_open_message implementation
1 parent 9d0a9fa commit dca5fc6

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

mithril-aggregator/src/runtime/runner.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,24 @@ impl AggregatorRunnerTrait for AggregatorRunner {
183183
"AggregatorRunner can not create the list of allowed signed entity types"
184184
})?;
185185
for signed_entity_type in signed_entity_types {
186-
if let Some(open_message) = self
187-
.get_current_open_message_for_signed_entity_type(&signed_entity_type)
186+
let current_open_message = self.get_current_open_message_for_signed_entity_type(&signed_entity_type)
188187
.await
189-
.with_context(|| format!("AggregatorRunner can not get current open message for signed entity type: '{}'", &signed_entity_type))?
190-
{
191-
if !open_message.is_certified && !open_message.is_expired {
192-
return Ok(Some(open_message));
188+
.with_context(|| format!("AggregatorRunner can not get current open message for signed entity type: '{}'", &signed_entity_type))?;
189+
match current_open_message {
190+
None => {
191+
let protocol_message = self.compute_protocol_message(&signed_entity_type).await.with_context(|| format!("AggregatorRunner can not compute protocol message for signed_entity_type: '{signed_entity_type}'"))?;
192+
let open_message_new = self.create_open_message(&signed_entity_type, &protocol_message)
193+
.await
194+
.with_context(|| format!("AggregatorRunner can not create open message for signed_entity_type: '{signed_entity_type}'"))?;
195+
196+
return Ok(Some(open_message_new));
197+
}
198+
Some(open_message) => {
199+
if !open_message.is_certified && !open_message.is_expired {
200+
return Ok(Some(open_message));
201+
}
193202
}
194-
continue;
195203
}
196-
let protocol_message = self.compute_protocol_message(&signed_entity_type).await.with_context(|| format!("AggregatorRunner can not compute protocol message for signed_entity_type: '{signed_entity_type}'"))?;
197-
let open_message_new = self.create_open_message(&signed_entity_type, &protocol_message)
198-
.await
199-
.with_context(|| format!("AggregatorRunner can not create open message for signed_entity_type: '{signed_entity_type}'"))?;
200-
201-
return Ok(Some(open_message_new));
202204
}
203205

204206
Ok(None)

0 commit comments

Comments
 (0)