@@ -2,9 +2,9 @@ use std::error::Error;
2
2
3
3
use chrono:: { TimeZone , Utc } ;
4
4
5
- use primitives:: { BalancesMap , Channel } ;
6
5
use primitives:: adapter:: Adapter ;
7
6
use primitives:: validator:: { Accounting , MessageTypes } ;
7
+ use primitives:: { BalancesMap , Channel } ;
8
8
9
9
use crate :: core:: events:: merge_aggrs;
10
10
use crate :: sentry_interface:: SentryApi ;
@@ -14,20 +14,22 @@ pub type Result = std::result::Result<(BalancesMap, Option<MessageTypes>), Box<d
14
14
pub async fn tick < A : Adapter + ' static > ( iface : & SentryApi < A > ) -> Result {
15
15
let validator_msg_resp = await ! ( iface. get_our_latest_msg( "Accounting" . to_owned( ) ) ) ?;
16
16
17
- let accounting = validator_msg_resp. msg . get ( 0 ) . and_then ( |accounting| match accounting {
18
- MessageTypes :: Accounting ( accounting) => Some ( accounting. to_owned ( ) ) ,
19
- _ => None ,
20
- } ) . unwrap_or_else ( || {
21
- Accounting {
17
+ let accounting = validator_msg_resp
18
+ . msg
19
+ . get ( 0 )
20
+ . and_then ( |accounting| match accounting {
21
+ MessageTypes :: Accounting ( accounting) => Some ( accounting. to_owned ( ) ) ,
22
+ _ => None ,
23
+ } )
24
+ . unwrap_or_else ( || Accounting {
22
25
last_event_aggregate : Utc . timestamp ( 0 , 0 ) ,
23
26
balances_before_fees : Default :: default ( ) ,
24
27
balances : Default :: default ( ) ,
25
- }
26
- } ) ;
28
+ } ) ;
27
29
28
30
let aggrs = await ! ( iface. get_event_aggregates( accounting. last_event_aggregate) ) ?;
29
31
30
- if aggrs. events . len ( ) > 0 {
32
+ if ! aggrs. events . is_empty ( ) {
31
33
// TODO: Log the merge
32
34
let ( balances, new_accounting) = merge_aggrs ( & accounting, & aggrs. events , & iface. channel ) ?;
33
35
0 commit comments