@@ -120,8 +120,7 @@ impl DefaultNotificationService {
120120 . await
121121 {
122122 error ! (
123- "Failed to send block notification, will add it to retry queue: {}" ,
124- e
123+ "Failed to send block notification, will add it to retry queue: {e}"
125124 ) ;
126125 let queue_message = NostrQueuedMessage {
127126 id : uuid:: Uuid :: new_v4 ( ) . to_string ( ) ,
@@ -134,18 +133,15 @@ impl DefaultNotificationService {
134133 . add_message ( queue_message, Self :: NOSTR_MAX_RETRIES )
135134 . await
136135 {
137- error ! ( "Failed to add block notification to retry queue: {}" , e ) ;
136+ error ! ( "Failed to add block notification to retry queue: {e}" ) ;
138137 }
139138 }
140139 } else {
141- warn ! (
142- "Failed to find recipient in contacts for node_id: {}" ,
143- node_id
144- ) ;
140+ warn ! ( "Failed to find recipient in contacts for node_id: {node_id}" ) ;
145141 }
146142 }
147143 } else {
148- warn ! ( "No transport node found for sender node_id: {}" , sender ) ;
144+ warn ! ( "No transport node found for sender node_id: {sender}" ) ;
149145 }
150146 Ok ( ( ) )
151147 }
@@ -206,6 +202,7 @@ impl DefaultNotificationService {
206202 received : block_event. data . block . timestamp ,
207203 time : event. created_at . as_u64 ( ) ,
208204 payload : event,
205+ valid : true ,
209206 } )
210207 . await
211208 . map_err ( |_| {
@@ -263,8 +260,8 @@ impl NotificationServiceApi for DefaultNotificationService {
263260 None ,
264261 ) ;
265262
266- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
267263 self . send_bill_chain_events ( event) . await ?;
264+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
268265 Ok ( ( ) )
269266 }
270267
@@ -277,8 +274,8 @@ impl NotificationServiceApi for DefaultNotificationService {
277274 None ,
278275 None ,
279276 ) ;
280- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
281277 self . send_bill_chain_events ( event) . await ?;
278+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
282279 Ok ( ( ) )
283280 }
284281
@@ -294,8 +291,8 @@ impl NotificationServiceApi for DefaultNotificationService {
294291 None ,
295292 None ,
296293 ) ;
297- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
298294 self . send_bill_chain_events ( event) . await ?;
295+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
299296 Ok ( ( ) )
300297 }
301298
@@ -308,8 +305,8 @@ impl NotificationServiceApi for DefaultNotificationService {
308305 None ,
309306 None ,
310307 ) ;
311- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
312308 self . send_bill_chain_events ( event) . await ?;
309+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
313310 Ok ( ( ) )
314311 }
315312
@@ -322,8 +319,8 @@ impl NotificationServiceApi for DefaultNotificationService {
322319 None ,
323320 None ,
324321 ) ;
325- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
326322 self . send_bill_chain_events ( event) . await ?;
323+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
327324 Ok ( ( ) )
328325 }
329326
@@ -336,8 +333,8 @@ impl NotificationServiceApi for DefaultNotificationService {
336333 None ,
337334 None ,
338335 ) ;
339- self . send_all_events ( & bill. sender ( ) , all_events) . await ?;
340336 self . send_bill_chain_events ( bill) . await ?;
337+ self . send_all_events ( & bill. sender ( ) , all_events) . await ?;
341338 Ok ( ( ) )
342339 }
343340
@@ -354,8 +351,8 @@ impl NotificationServiceApi for DefaultNotificationService {
354351 None ,
355352 None ,
356353 ) ;
357- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
358354 self . send_bill_chain_events ( event) . await ?;
355+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
359356 Ok ( ( ) )
360357 }
361358
@@ -372,8 +369,8 @@ impl NotificationServiceApi for DefaultNotificationService {
372369 None ,
373370 None ,
374371 ) ;
375- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
376372 self . send_bill_chain_events ( event) . await ?;
373+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
377374 Ok ( ( ) )
378375 }
379376
@@ -390,8 +387,8 @@ impl NotificationServiceApi for DefaultNotificationService {
390387 None ,
391388 None ,
392389 ) ;
393- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
394390 self . send_bill_chain_events ( event) . await ?;
391+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
395392 Ok ( ( ) )
396393 }
397394
@@ -406,8 +403,6 @@ impl NotificationServiceApi for DefaultNotificationService {
406403 bill_id : bill. id . clone ( ) ,
407404 action_type : Some ( ActionType :: CheckBill ) ,
408405 sum : Some ( bill. sum ) ,
409- keys : None ,
410- blocks : vec ! [ ] ,
411406 } ) ;
412407 if let Some ( node) = self . notification_transport . get ( sender_node_id) {
413408 node. send_private_event ( mint, event. try_into ( ) ?) . await ?;
@@ -451,8 +446,6 @@ impl NotificationServiceApi for DefaultNotificationService {
451446 bill_id : bill_id. to_owned ( ) ,
452447 action_type : Some ( ActionType :: CheckBill ) ,
453448 sum,
454- keys : None ,
455- blocks : vec ! [ ] ,
456449 } ;
457450 for ( _, recipient) in unique {
458451 let event = Event :: new_bill ( payload. clone ( ) ) ;
@@ -479,8 +472,8 @@ impl NotificationServiceApi for DefaultNotificationService {
479472 Some ( BillEventType :: BillBlock ) ,
480473 None ,
481474 ) ;
482- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
483475 self . send_bill_chain_events ( event) . await ?;
476+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
484477 }
485478 Ok ( ( ) )
486479 }
@@ -503,7 +496,7 @@ impl NotificationServiceApi for DefaultNotificationService {
503496 validate_node_id_network ( node_id) ?;
504497 }
505498 let result = self . notification_store . list ( filter) . await . map_err ( |e| {
506- error ! ( "Failed to get client notifications: {}" , e ) ;
499+ error ! ( "Failed to get client notifications: {e}" ) ;
507500 Error :: Persistence ( "Failed to get client notifications" . to_string ( ) )
508501 } ) ?;
509502 Ok ( result)
@@ -515,7 +508,7 @@ impl NotificationServiceApi for DefaultNotificationService {
515508 . mark_as_done ( notification_id)
516509 . await
517510 . map_err ( |e| {
518- error ! ( "Failed to mark notification as done: {}" , e ) ;
511+ error ! ( "Failed to mark notification as done: {e}" ) ;
519512 Error :: Persistence ( "Failed to mark notification as done" . to_string ( ) )
520513 } ) ?;
521514 Ok ( ( ) )
@@ -559,10 +552,7 @@ impl NotificationServiceApi for DefaultNotificationService {
559552 . bill_notification_sent ( bill_id, block_height, action)
560553 . await
561554 . map_err ( |e| {
562- error ! (
563- "Failed to check if bill notification was already sent: {}" ,
564- e
565- ) ;
555+ error ! ( "Failed to check if bill notification was already sent: {e}" ) ;
566556 Error :: Persistence (
567557 "Failed to check if bill notification was already sent" . to_string ( ) ,
568558 )
@@ -581,7 +571,7 @@ impl NotificationServiceApi for DefaultNotificationService {
581571 . set_bill_notification_sent ( bill_id, block_height, action)
582572 . await
583573 . map_err ( |e| {
584- error ! ( "Failed to mark bill notification as sent: {}" , e ) ;
574+ error ! ( "Failed to mark bill notification as sent: {e}" ) ;
585575 Error :: Persistence ( "Failed to mark bill notification as sent" . to_string ( ) )
586576 } ) ?;
587577 Ok ( ( ) )
@@ -604,21 +594,21 @@ impl NotificationServiceApi for DefaultNotificationService {
604594 )
605595 . await
606596 {
607- error ! ( "Failed to send retry message: {}" , e ) ;
597+ error ! ( "Failed to send retry message: {e}" ) ;
608598 failed_ids. push ( queued_message. id . clone ( ) ) ;
609599 } else if let Err ( e) = self
610600 . queued_message_store
611601 . succeed_retry ( & queued_message. id )
612602 . await
613603 {
614- error ! ( "Failed to mark retry message as sent: {}" , e ) ;
604+ error ! ( "Failed to mark retry message as sent: {e}" ) ;
615605 }
616606 }
617607 }
618608
619609 for failed in failed_ids {
620610 if let Err ( e) = self . queued_message_store . fail_retry ( & failed) . await {
621- error ! ( "Failed to store failed retry attemt: {}" , e ) ;
611+ error ! ( "Failed to store failed retry attemt: {e}" ) ;
622612 }
623613 }
624614 Ok ( ( ) )
@@ -1248,32 +1238,32 @@ mod tests {
12481238 let mut mock = MockNotificationJsonTransport :: new ( ) ;
12491239 mock. expect_get_sender_node_id ( ) . returning ( node_id_test) ;
12501240
1251- mock. expect_send_private_event ( )
1252- . returning ( |_, _| Ok ( ( ) ) )
1253- . once ( ) ;
1254-
12551241 mock. expect_send_private_event ( )
12561242 . withf ( move |_, e| {
12571243 let r: Result < Event < ChainInvite > > = e. clone ( ) . try_into ( ) ;
1258- r. is_err ( )
1244+ r. is_ok ( )
12591245 } )
1260- . returning ( |_, _| Err ( Error :: Network ( "Failed to send" . to_string ( ) ) ) ) ;
1246+ . returning ( |_, _| Ok ( ( ) ) ) ;
12611247
12621248 mock. expect_send_public_chain_event ( )
12631249 . returning ( |_, _, _, _, _, _, _| Ok ( get_test_nostr_event ( ) ) ) ;
12641250
1265- mock. expect_send_private_event ( )
1266- . withf ( move |_, e| {
1267- let r: Result < Event < ChainInvite > > = e. clone ( ) . try_into ( ) ;
1268- r. is_ok ( )
1269- } )
1270- . returning ( |_, _| Ok ( ( ) ) ) ;
1271-
12721251 let mock_event_store = setup_event_store_expectations (
12731252 chain. get_latest_block ( ) . previous_hash . to_owned ( ) . as_str ( ) ,
12741253 & bill. id ,
12751254 ) ;
12761255
1256+ mock. expect_send_private_event ( )
1257+ . returning ( |_, _| Ok ( ( ) ) )
1258+ . once ( ) ;
1259+
1260+ mock. expect_send_private_event ( )
1261+ . withf ( move |_, e| {
1262+ let r: Result < Event < ChainInvite > > = e. clone ( ) . try_into ( ) ;
1263+ r. is_err ( )
1264+ } )
1265+ . returning ( |_, _| Err ( Error :: Network ( "Failed to send" . to_string ( ) ) ) ) ;
1266+
12771267 let mut queue_mock = MockNostrQueuedMessageStore :: new ( ) ;
12781268 queue_mock
12791269 . expect_add_message ( )
0 commit comments