File tree Expand file tree Collapse file tree 3 files changed +10
-18
lines changed
mithril-signer/src/database Expand file tree Collapse file tree 3 files changed +10
-18
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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) ?) ?;
You can’t perform that action at this time.
0 commit comments