@@ -499,7 +499,7 @@ impl PeerState {
499
499
}
500
500
501
501
macro_rules! get_or_insert_peer_state_entry {
502
- ( $self: ident, $outer_state_lock: expr, $counterparty_node_id: expr) => { {
502
+ ( $self: ident, $outer_state_lock: expr, $message_queue_notifier : expr , $ counterparty_node_id: expr) => { {
503
503
// Return an internal error and abort if we hit the maximum allowed number of total peers.
504
504
let is_limited_by_max_total_peers = $outer_state_lock. len( ) >= MAX_TOTAL_PEERS ;
505
505
match $outer_state_lock. entry( * $counterparty_node_id) {
@@ -512,7 +512,7 @@ macro_rules! get_or_insert_peer_state_entry {
512
512
513
513
let msg = LSPSMessage :: Invalid ( error_response) ;
514
514
drop( $outer_state_lock) ;
515
- $self . pending_messages . enqueue( $counterparty_node_id, msg) ;
515
+ $message_queue_notifier . enqueue( $counterparty_node_id, msg) ;
516
516
517
517
let err = format!(
518
518
"Dropping request from peer {} due to reaching maximally allowed number of total peers: {}" ,
@@ -581,6 +581,7 @@ where
581
581
pub fn invalid_token_provided (
582
582
& self , counterparty_node_id : & PublicKey , request_id : LSPSRequestId ,
583
583
) -> Result < ( ) , APIError > {
584
+ let mut message_queue_notifier = self . pending_messages . notifier ( ) ;
584
585
let ( result, response) = {
585
586
let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
586
587
@@ -622,7 +623,7 @@ where
622
623
623
624
if let Some ( response) = response {
624
625
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
625
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
626
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
626
627
}
627
628
628
629
result
@@ -637,6 +638,7 @@ where
637
638
& self , counterparty_node_id : & PublicKey , request_id : LSPSRequestId ,
638
639
opening_fee_params_menu : Vec < LSPS2RawOpeningFeeParams > ,
639
640
) -> Result < ( ) , APIError > {
641
+ let mut message_queue_notifier = self . pending_messages . notifier ( ) ;
640
642
let ( result, response) = {
641
643
let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
642
644
@@ -689,7 +691,7 @@ where
689
691
690
692
if let Some ( response) = response {
691
693
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
692
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
694
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
693
695
}
694
696
695
697
result
@@ -707,6 +709,8 @@ where
707
709
& self , counterparty_node_id : & PublicKey , request_id : LSPSRequestId , intercept_scid : u64 ,
708
710
cltv_expiry_delta : u32 , client_trusts_lsp : bool , user_channel_id : u128 ,
709
711
) -> Result < ( ) , APIError > {
712
+ let mut message_queue_notifier = self . pending_messages . notifier ( ) ;
713
+
710
714
let ( result, response) = {
711
715
let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
712
716
@@ -767,7 +771,7 @@ where
767
771
768
772
if let Some ( response) = response {
769
773
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
770
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
774
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
771
775
}
772
776
773
777
result
@@ -1202,11 +1206,16 @@ where
1202
1206
& self , request_id : LSPSRequestId , counterparty_node_id : & PublicKey ,
1203
1207
params : LSPS2GetInfoRequest ,
1204
1208
) -> Result < ( ) , LightningError > {
1209
+ let mut message_queue_notifier = self . pending_messages . notifier ( ) ;
1205
1210
let event_queue_notifier = self . pending_events . notifier ( ) ;
1206
1211
let ( result, response) = {
1207
1212
let mut outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
1208
- let inner_state_lock =
1209
- get_or_insert_peer_state_entry ! ( self , outer_state_lock, counterparty_node_id) ;
1213
+ let inner_state_lock = get_or_insert_peer_state_entry ! (
1214
+ self ,
1215
+ outer_state_lock,
1216
+ message_queue_notifier,
1217
+ counterparty_node_id
1218
+ ) ;
1210
1219
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
1211
1220
let request = LSPS2Request :: GetInfo ( params. clone ( ) ) ;
1212
1221
match self . insert_pending_request (
@@ -1229,7 +1238,7 @@ where
1229
1238
} ;
1230
1239
1231
1240
if let Some ( msg) = response {
1232
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1241
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1233
1242
}
1234
1243
1235
1244
result
@@ -1238,6 +1247,7 @@ where
1238
1247
fn handle_buy_request (
1239
1248
& self , request_id : LSPSRequestId , counterparty_node_id : & PublicKey , params : LSPS2BuyRequest ,
1240
1249
) -> Result < ( ) , LightningError > {
1250
+ let mut message_queue_notifier = self . pending_messages . notifier ( ) ;
1241
1251
let event_queue_notifier = self . pending_events . notifier ( ) ;
1242
1252
if let Some ( payment_size_msat) = params. payment_size_msat {
1243
1253
if payment_size_msat < params. opening_fee_params . min_payment_size_msat {
@@ -1247,7 +1257,7 @@ where
1247
1257
data : None ,
1248
1258
} ) ;
1249
1259
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
1250
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1260
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1251
1261
1252
1262
return Err ( LightningError {
1253
1263
err : "payment size is below our minimum supported payment size" . to_string ( ) ,
@@ -1262,7 +1272,7 @@ where
1262
1272
data : None ,
1263
1273
} ) ;
1264
1274
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
1265
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1275
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1266
1276
return Err ( LightningError {
1267
1277
err : "payment size is above our maximum supported payment size" . to_string ( ) ,
1268
1278
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
@@ -1283,7 +1293,7 @@ where
1283
1293
data : None ,
1284
1294
} ) ;
1285
1295
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
1286
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1296
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1287
1297
return Err ( LightningError {
1288
1298
err : "payment size is too small to cover the opening fee" . to_string ( ) ,
1289
1299
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
@@ -1297,7 +1307,7 @@ where
1297
1307
data : None ,
1298
1308
} ) ;
1299
1309
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
1300
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1310
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1301
1311
return Err ( LightningError {
1302
1312
err : "overflow error when calculating opening_fee" . to_string ( ) ,
1303
1313
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
@@ -1314,7 +1324,7 @@ where
1314
1324
data : None ,
1315
1325
} ) ;
1316
1326
let msg = LSPS2Message :: Response ( request_id, response) . into ( ) ;
1317
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1327
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1318
1328
return Err ( LightningError {
1319
1329
err : "invalid opening fee parameters were supplied by client" . to_string ( ) ,
1320
1330
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
@@ -1323,8 +1333,12 @@ where
1323
1333
1324
1334
let ( result, response) = {
1325
1335
let mut outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
1326
- let inner_state_lock =
1327
- get_or_insert_peer_state_entry ! ( self , outer_state_lock, counterparty_node_id) ;
1336
+ let inner_state_lock = get_or_insert_peer_state_entry ! (
1337
+ self ,
1338
+ outer_state_lock,
1339
+ message_queue_notifier,
1340
+ counterparty_node_id
1341
+ ) ;
1328
1342
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
1329
1343
1330
1344
let request = LSPS2Request :: Buy ( params. clone ( ) ) ;
@@ -1350,7 +1364,7 @@ where
1350
1364
} ;
1351
1365
1352
1366
if let Some ( msg) = response {
1353
- self . pending_messages . enqueue ( counterparty_node_id, msg) ;
1367
+ message_queue_notifier . enqueue ( counterparty_node_id, msg) ;
1354
1368
}
1355
1369
1356
1370
result
0 commit comments