Skip to content

Commit 4d66fb9

Browse files
committed
style: adjustments following pr reviews
1 parent 0dfa192 commit 4d66fb9

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

mithril-signer/src/database/query/signed_beacon/get_signed_beacon.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ impl GetSignedBeaconQuery {
3434
let condition = match signed_entity_types {
3535
[] => WhereCondition::new("false", vec![]),
3636
[first, rest @ ..] => {
37-
let mut condition = signed_entity_condition(first)?;
38-
39-
for entity in rest {
40-
condition = condition.or_where(signed_entity_condition(entity)?);
41-
}
42-
43-
condition
37+
rest.iter()
38+
.try_fold(signed_entity_condition(first)?, |condition, entity| {
39+
StdResult::Ok(condition.or_where(signed_entity_condition(entity)?))
40+
})?
4441
}
4542
};
4643

@@ -56,9 +53,9 @@ impl Query for GetSignedBeaconQuery {
5653
}
5754

5855
fn get_definition(&self, condition: &str) -> String {
59-
let aliases = SourceAlias::new(&[("{:signed_beacon:}", "b")]);
56+
let aliases = SourceAlias::new(&[("{:signed_beacon:}", "signed_beacon")]);
6057
let projection = Self::Entity::get_projection().expand(aliases);
61-
format!("select {projection} from signed_beacon as b where {condition} order by ROWID desc")
58+
format!("select {projection} from signed_beacon where {condition} order by rowid desc")
6259
}
6360
}
6461

mithril-signer/src/database/record/signed_beacon_record.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ impl SqLiteEntity for SignedBeaconRecord {
8686
let beacon_str = Hydrator::read_signed_entity_beacon_column(&row, 1);
8787
let signed_entity_type_id = usize::try_from(row.read::<i64, _>(2)).map_err(|e| {
8888
panic!(
89-
"Integer field open_message.signed_entity_type_id cannot be turned into usize: {e}"
89+
"Integer field signed_beacon.signed_entity_type_id cannot be turned into usize: {e}"
9090
)
9191
})?;
9292
let initiated_at = &row.read::<&str, _>(3);
9393
let signed_at = &row.read::<&str, _>(4);
9494

95-
let open_message = Self {
95+
let signed_beacon = Self {
9696
epoch: Epoch(epoch.try_into().map_err(|e| {
9797
HydrationError::InvalidData(format!(
9898
"Could not cast i64 ({epoch}) to u64. Error: '{e}'"
@@ -111,7 +111,7 @@ impl SqLiteEntity for SignedBeaconRecord {
111111
})?.with_timezone(&Utc),
112112
};
113113

114-
Ok(open_message)
114+
Ok(signed_beacon)
115115
}
116116

117117
fn get_projection() -> Projection {

mithril-signer/src/database/repository/signed_beacon_repository.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ impl SignedBeaconStore for SignedBeaconRepository {
5656
}
5757

5858
async fn mark_beacon_as_signed(&self, entity: &BeaconToSign) -> StdResult<()> {
59-
let record = SignedBeaconRecord {
60-
epoch: entity.epoch,
61-
signed_entity_type: entity.signed_entity_type.clone(),
62-
initiated_at: entity.initiated_at,
63-
signed_at: chrono::Utc::now(),
64-
};
59+
let record = entity.clone().into();
6560
let _ = self
6661
.connection
6762
.fetch_first(InsertSignedBeaconRecordQuery::one(record)?)?;

0 commit comments

Comments
 (0)