@@ -120,8 +120,7 @@ impl DefaultNotificationService {
120
120
. await
121
121
{
122
122
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}"
125
124
) ;
126
125
let queue_message = NostrQueuedMessage {
127
126
id : uuid:: Uuid :: new_v4 ( ) . to_string ( ) ,
@@ -134,18 +133,15 @@ impl DefaultNotificationService {
134
133
. add_message ( queue_message, Self :: NOSTR_MAX_RETRIES )
135
134
. await
136
135
{
137
- error ! ( "Failed to add block notification to retry queue: {}" , e ) ;
136
+ error ! ( "Failed to add block notification to retry queue: {e}" ) ;
138
137
}
139
138
}
140
139
} 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}" ) ;
145
141
}
146
142
}
147
143
} else {
148
- warn ! ( "No transport node found for sender node_id: {}" , sender ) ;
144
+ warn ! ( "No transport node found for sender node_id: {sender}" ) ;
149
145
}
150
146
Ok ( ( ) )
151
147
}
@@ -206,6 +202,7 @@ impl DefaultNotificationService {
206
202
received : block_event. data . block . timestamp ,
207
203
time : event. created_at . as_u64 ( ) ,
208
204
payload : event,
205
+ valid : true ,
209
206
} )
210
207
. await
211
208
. map_err ( |_| {
@@ -263,8 +260,8 @@ impl NotificationServiceApi for DefaultNotificationService {
263
260
None ,
264
261
) ;
265
262
266
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
267
263
self . send_bill_chain_events ( event) . await ?;
264
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
268
265
Ok ( ( ) )
269
266
}
270
267
@@ -277,8 +274,8 @@ impl NotificationServiceApi for DefaultNotificationService {
277
274
None ,
278
275
None ,
279
276
) ;
280
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
281
277
self . send_bill_chain_events ( event) . await ?;
278
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
282
279
Ok ( ( ) )
283
280
}
284
281
@@ -294,8 +291,8 @@ impl NotificationServiceApi for DefaultNotificationService {
294
291
None ,
295
292
None ,
296
293
) ;
297
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
298
294
self . send_bill_chain_events ( event) . await ?;
295
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
299
296
Ok ( ( ) )
300
297
}
301
298
@@ -308,8 +305,8 @@ impl NotificationServiceApi for DefaultNotificationService {
308
305
None ,
309
306
None ,
310
307
) ;
311
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
312
308
self . send_bill_chain_events ( event) . await ?;
309
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
313
310
Ok ( ( ) )
314
311
}
315
312
@@ -322,8 +319,8 @@ impl NotificationServiceApi for DefaultNotificationService {
322
319
None ,
323
320
None ,
324
321
) ;
325
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
326
322
self . send_bill_chain_events ( event) . await ?;
323
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
327
324
Ok ( ( ) )
328
325
}
329
326
@@ -336,8 +333,8 @@ impl NotificationServiceApi for DefaultNotificationService {
336
333
None ,
337
334
None ,
338
335
) ;
339
- self . send_all_events ( & bill. sender ( ) , all_events) . await ?;
340
336
self . send_bill_chain_events ( bill) . await ?;
337
+ self . send_all_events ( & bill. sender ( ) , all_events) . await ?;
341
338
Ok ( ( ) )
342
339
}
343
340
@@ -354,8 +351,8 @@ impl NotificationServiceApi for DefaultNotificationService {
354
351
None ,
355
352
None ,
356
353
) ;
357
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
358
354
self . send_bill_chain_events ( event) . await ?;
355
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
359
356
Ok ( ( ) )
360
357
}
361
358
@@ -372,8 +369,8 @@ impl NotificationServiceApi for DefaultNotificationService {
372
369
None ,
373
370
None ,
374
371
) ;
375
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
376
372
self . send_bill_chain_events ( event) . await ?;
373
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
377
374
Ok ( ( ) )
378
375
}
379
376
@@ -390,8 +387,8 @@ impl NotificationServiceApi for DefaultNotificationService {
390
387
None ,
391
388
None ,
392
389
) ;
393
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
394
390
self . send_bill_chain_events ( event) . await ?;
391
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
395
392
Ok ( ( ) )
396
393
}
397
394
@@ -406,8 +403,6 @@ impl NotificationServiceApi for DefaultNotificationService {
406
403
bill_id : bill. id . clone ( ) ,
407
404
action_type : Some ( ActionType :: CheckBill ) ,
408
405
sum : Some ( bill. sum ) ,
409
- keys : None ,
410
- blocks : vec ! [ ] ,
411
406
} ) ;
412
407
if let Some ( node) = self . notification_transport . get ( sender_node_id) {
413
408
node. send_private_event ( mint, event. try_into ( ) ?) . await ?;
@@ -451,8 +446,6 @@ impl NotificationServiceApi for DefaultNotificationService {
451
446
bill_id : bill_id. to_owned ( ) ,
452
447
action_type : Some ( ActionType :: CheckBill ) ,
453
448
sum,
454
- keys : None ,
455
- blocks : vec ! [ ] ,
456
449
} ;
457
450
for ( _, recipient) in unique {
458
451
let event = Event :: new_bill ( payload. clone ( ) ) ;
@@ -479,8 +472,8 @@ impl NotificationServiceApi for DefaultNotificationService {
479
472
Some ( BillEventType :: BillBlock ) ,
480
473
None ,
481
474
) ;
482
- self . send_all_events ( & event. sender ( ) , all_events) . await ?;
483
475
self . send_bill_chain_events ( event) . await ?;
476
+ self . send_all_events ( & event. sender ( ) , all_events) . await ?;
484
477
}
485
478
Ok ( ( ) )
486
479
}
@@ -503,7 +496,7 @@ impl NotificationServiceApi for DefaultNotificationService {
503
496
validate_node_id_network ( node_id) ?;
504
497
}
505
498
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}" ) ;
507
500
Error :: Persistence ( "Failed to get client notifications" . to_string ( ) )
508
501
} ) ?;
509
502
Ok ( result)
@@ -515,7 +508,7 @@ impl NotificationServiceApi for DefaultNotificationService {
515
508
. mark_as_done ( notification_id)
516
509
. await
517
510
. map_err ( |e| {
518
- error ! ( "Failed to mark notification as done: {}" , e ) ;
511
+ error ! ( "Failed to mark notification as done: {e}" ) ;
519
512
Error :: Persistence ( "Failed to mark notification as done" . to_string ( ) )
520
513
} ) ?;
521
514
Ok ( ( ) )
@@ -559,10 +552,7 @@ impl NotificationServiceApi for DefaultNotificationService {
559
552
. bill_notification_sent ( bill_id, block_height, action)
560
553
. await
561
554
. 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}" ) ;
566
556
Error :: Persistence (
567
557
"Failed to check if bill notification was already sent" . to_string ( ) ,
568
558
)
@@ -581,7 +571,7 @@ impl NotificationServiceApi for DefaultNotificationService {
581
571
. set_bill_notification_sent ( bill_id, block_height, action)
582
572
. await
583
573
. map_err ( |e| {
584
- error ! ( "Failed to mark bill notification as sent: {}" , e ) ;
574
+ error ! ( "Failed to mark bill notification as sent: {e}" ) ;
585
575
Error :: Persistence ( "Failed to mark bill notification as sent" . to_string ( ) )
586
576
} ) ?;
587
577
Ok ( ( ) )
@@ -604,21 +594,21 @@ impl NotificationServiceApi for DefaultNotificationService {
604
594
)
605
595
. await
606
596
{
607
- error ! ( "Failed to send retry message: {}" , e ) ;
597
+ error ! ( "Failed to send retry message: {e}" ) ;
608
598
failed_ids. push ( queued_message. id . clone ( ) ) ;
609
599
} else if let Err ( e) = self
610
600
. queued_message_store
611
601
. succeed_retry ( & queued_message. id )
612
602
. await
613
603
{
614
- error ! ( "Failed to mark retry message as sent: {}" , e ) ;
604
+ error ! ( "Failed to mark retry message as sent: {e}" ) ;
615
605
}
616
606
}
617
607
}
618
608
619
609
for failed in failed_ids {
620
610
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}" ) ;
622
612
}
623
613
}
624
614
Ok ( ( ) )
@@ -1248,32 +1238,32 @@ mod tests {
1248
1238
let mut mock = MockNotificationJsonTransport :: new ( ) ;
1249
1239
mock. expect_get_sender_node_id ( ) . returning ( node_id_test) ;
1250
1240
1251
- mock. expect_send_private_event ( )
1252
- . returning ( |_, _| Ok ( ( ) ) )
1253
- . once ( ) ;
1254
-
1255
1241
mock. expect_send_private_event ( )
1256
1242
. withf ( move |_, e| {
1257
1243
let r: Result < Event < ChainInvite > > = e. clone ( ) . try_into ( ) ;
1258
- r. is_err ( )
1244
+ r. is_ok ( )
1259
1245
} )
1260
- . returning ( |_, _| Err ( Error :: Network ( "Failed to send" . to_string ( ) ) ) ) ;
1246
+ . returning ( |_, _| Ok ( ( ) ) ) ;
1261
1247
1262
1248
mock. expect_send_public_chain_event ( )
1263
1249
. returning ( |_, _, _, _, _, _, _| Ok ( get_test_nostr_event ( ) ) ) ;
1264
1250
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
-
1272
1251
let mock_event_store = setup_event_store_expectations (
1273
1252
chain. get_latest_block ( ) . previous_hash . to_owned ( ) . as_str ( ) ,
1274
1253
& bill. id ,
1275
1254
) ;
1276
1255
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
+
1277
1267
let mut queue_mock = MockNostrQueuedMessageStore :: new ( ) ;
1278
1268
queue_mock
1279
1269
. expect_add_message ( )
0 commit comments