Skip to content

Commit fd9a9f2

Browse files
committed
Also reset notification cooldown on peer disconnection
If we happened to send a notification while the client is connected to us, we would previously only reset the cooldown once the client connects again. While theoretically it would be preferable to never set the `last_notification_sent` field to begin with if the client is connected to us, allowing the service handler to query the peer connection state would be unnecessarily complex. Here, we therefore simply opt to also reset the `last_notification_sent` state once the peer disconnects from us.
1 parent 5bb9f9b commit fd9a9f2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lightning-liquidity/src/lsps5/service.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,15 @@ where
526526
}
527527
}
528528
}
529+
530+
pub(crate) fn peer_disconnected(&self, counterparty_node_id: &PublicKey) {
531+
let mut webhooks = self.webhooks.lock().unwrap();
532+
if let Some(client_webhooks) = webhooks.get_mut(counterparty_node_id) {
533+
for webhook in client_webhooks.values_mut() {
534+
webhook.last_notification_sent = None;
535+
}
536+
}
537+
}
529538
}
530539

531540
impl<CM: Deref, NS: Deref, TP: Deref> LSPSProtocolMessageHandler for LSPS5ServiceHandler<CM, NS, TP>

lightning-liquidity/src/manager.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,10 @@ where
712712
if let Some(lsps2_service_handler) = self.lsps2_service_handler.as_ref() {
713713
lsps2_service_handler.peer_disconnected(counterparty_node_id);
714714
}
715+
716+
if let Some(lsps5_service_handler) = self.lsps5_service_handler.as_ref() {
717+
lsps5_service_handler.peer_disconnected(&counterparty_node_id);
718+
}
715719
}
716720
fn peer_connected(
717721
&self, counterparty_node_id: bitcoin::secp256k1::PublicKey, _: &lightning::ln::msgs::Init,

0 commit comments

Comments
 (0)