1
- use self :: channel_list:: { ChannelListQuery , LastApprovedQuery } ;
2
- use crate :: db:: event_aggregate:: { lastest_approve_state, latest_heartbeats, latest_new_state} ;
1
+ use crate :: db:: event_aggregate:: { latest_approve_state, latest_heartbeats, latest_new_state} ;
3
2
use crate :: db:: { get_channel_by_id, insert_channel, insert_validator_messages, list_channels} ;
4
- use crate :: success_response;
5
- use crate :: Application ;
6
- use crate :: ResponseError ;
7
- use crate :: RouteParams ;
8
- use crate :: { Auth , Session } ;
3
+ use crate :: { success_response, Application , Auth , ResponseError , RouteParams , Session } ;
9
4
use bb8:: RunError ;
10
5
use bb8_postgres:: tokio_postgres:: error;
11
6
use futures:: future:: try_join_all;
12
7
use hex:: FromHex ;
13
8
use hyper:: { Body , Request , Response } ;
14
- use primitives:: adapter:: Adapter ;
15
- use primitives:: sentry:: { Event , LastApproved , LastApprovedResponse , SuccessResponse } ;
16
- use primitives:: validator:: MessageTypes ;
17
- use primitives:: { Channel , ChannelId } ;
9
+ use primitives:: {
10
+ adapter:: Adapter ,
11
+ sentry:: {
12
+ channel_list:: { ChannelListQuery , LastApprovedQuery } ,
13
+ Event , LastApproved , LastApprovedResponse , SuccessResponse ,
14
+ } ,
15
+ validator:: MessageTypes ,
16
+ Channel , ChannelId ,
17
+ } ;
18
18
use slog:: error;
19
19
use std:: collections:: HashMap ;
20
20
@@ -130,7 +130,7 @@ pub async fn last_approved<A: Adapter>(
130
130
)
131
131
. expect ( "should build response" ) ;
132
132
133
- let approve_state = match lastest_approve_state ( & app. pool , & channel) . await ? {
133
+ let approve_state = match latest_approve_state ( & app. pool , & channel) . await ? {
134
134
Some ( approve_state) => approve_state,
135
135
None => return Ok ( default_response) ,
136
136
} ;
@@ -139,7 +139,7 @@ pub async fn last_approved<A: Adapter>(
139
139
MessageTypes :: ApproveState ( approve_state) => approve_state. state_root ,
140
140
_ => {
141
141
error ! ( & app. logger, "{}" , "failed to retrieve approved" ; "module" => "last_approved" ) ;
142
- return Err ( ResponseError :: BadRequest ( "an error occured " . to_string ( ) ) ) ;
142
+ return Err ( ResponseError :: BadRequest ( "an error occurred " . to_string ( ) ) ) ;
143
143
}
144
144
} ;
145
145
@@ -252,37 +252,3 @@ pub async fn create_validator_messages<A: Adapter + 'static>(
252
252
}
253
253
}
254
254
}
255
-
256
- mod channel_list {
257
- use chrono:: serde:: ts_seconds:: deserialize as ts_seconds;
258
- use chrono:: { DateTime , Utc } ;
259
- use primitives:: ValidatorId ;
260
- use serde:: Deserialize ;
261
-
262
- #[ derive( Debug , Deserialize ) ]
263
- pub ( super ) struct ChannelListQuery {
264
- #[ serde( default = "default_page" ) ]
265
- pub page : u64 ,
266
- /// filters the list on `valid_until >= valid_until_ge`
267
- /// It should be the same timestamp format as the `Channel.valid_until`: **seconds**
268
- #[ serde(
269
- deserialize_with = "ts_seconds" ,
270
- default = "Utc::now" ,
271
- rename = "validUntil"
272
- ) ]
273
- pub valid_until_ge : DateTime < Utc > ,
274
- pub creator : Option < String > ,
275
- /// filters the channels containing a specific validator if provided
276
- pub validator : Option < ValidatorId > ,
277
- }
278
-
279
- #[ derive( Debug , Deserialize ) ]
280
- #[ serde( rename_all = "camelCase" ) ]
281
- pub ( super ) struct LastApprovedQuery {
282
- pub with_heartbeat : Option < String > ,
283
- }
284
-
285
- fn default_page ( ) -> u64 {
286
- 0
287
- }
288
- }
0 commit comments