Skip to content

Commit 24712cf

Browse files
[LSP5] Change notification dooldown time to 1 minute, alsp update docs
1 parent c8450bf commit 24712cf

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

lightning-liquidity/src/lsps5/msgs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ pub enum LSPS5ProtocolError {
109109
/// A notification was sent too frequently.
110110
///
111111
/// This error indicates that the LSP is sending notifications
112-
/// too quickly, violating the notification cooldown [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]
112+
/// too quickly, violating the notification cooldown [`NOTIFICATION_COOLDOWN_TIME`]
113113
///
114-
/// [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]: super::service::DEFAULT_NOTIFICATION_COOLDOWN_HOURS
114+
/// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
115115
SlowDownError,
116116
}
117117

lightning-liquidity/src/lsps5/service.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ pub struct LSPS5ServiceConfig {
6868

6969
/// Default maximum number of webhooks allowed per client.
7070
pub const DEFAULT_MAX_WEBHOOKS_PER_CLIENT: u32 = 10;
71-
/// Default notification cooldown time in hours.
72-
pub const DEFAULT_NOTIFICATION_COOLDOWN_HOURS: Duration = Duration::from_secs(60 * 60); // 1 hour
71+
/// Default notification cooldown time in minutes.
72+
pub const NOTIFICATION_COOLDOWN_TIME: Duration = Duration::from_secs(60); // 1 minute
7373

7474
// Default configuration for LSPS5 service.
7575
impl Default for LSPS5ServiceConfig {
@@ -330,13 +330,13 @@ where
330330
/// node key, and enqueues HTTP POSTs to all registered webhook URLs for that client.
331331
///
332332
/// This may fail if a similar notification was sent too recently,
333-
/// violating the notification cooldown period defined in [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`].
333+
/// violating the notification cooldown period defined in [`NOTIFICATION_COOLDOWN_TIME`].
334334
///
335335
/// # Parameters
336336
/// - `client_id`: the client's node-ID whose webhooks should be invoked.
337337
///
338338
/// [`WebhookNotificationMethod::LSPS5PaymentIncoming`]: super::msgs::WebhookNotificationMethod::LSPS5PaymentIncoming
339-
/// [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]: super::service::DEFAULT_NOTIFICATION_COOLDOWN_HOURS
339+
/// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
340340
pub fn notify_payment_incoming(&self, client_id: PublicKey) -> Result<(), LSPS5ProtocolError> {
341341
let notification = WebhookNotification::payment_incoming();
342342
self.send_notifications_to_client_webhooks(client_id, notification)
@@ -351,14 +351,14 @@ where
351351
/// registered webhooks.
352352
///
353353
/// This may fail if a similar notification was sent too recently,
354-
/// violating the notification cooldown period defined in [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`].
354+
/// violating the notification cooldown period defined in [`NOTIFICATION_COOLDOWN_TIME`].
355355
///
356356
/// # Parameters
357357
/// - `client_id`: the client's node-ID whose webhooks should be invoked.
358358
/// - `timeout`: the block height at which the channel contract will expire.
359359
///
360360
/// [`WebhookNotificationMethod::LSPS5ExpirySoon`]: super::msgs::WebhookNotificationMethod::LSPS5ExpirySoon
361-
/// [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]: super::service::DEFAULT_NOTIFICATION_COOLDOWN_HOURS
361+
/// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
362362
pub fn notify_expiry_soon(
363363
&self, client_id: PublicKey, timeout: u32,
364364
) -> Result<(), LSPS5ProtocolError> {
@@ -373,13 +373,13 @@ where
373373
/// signs it, and sends it to all of the client's registered webhook URLs.
374374
///
375375
/// This may fail if a similar notification was sent too recently,
376-
/// violating the notification cooldown period defined in [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`].
376+
/// violating the notification cooldown period defined in [`NOTIFICATION_COOLDOWN_TIME`].
377377
///
378378
/// # Parameters
379379
/// - `client_id`: the client's node-ID whose webhooks should be invoked.
380380
///
381381
/// [`WebhookNotificationMethod::LSPS5LiquidityManagementRequest`]: super::msgs::WebhookNotificationMethod::LSPS5LiquidityManagementRequest
382-
/// [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]: super::service::DEFAULT_NOTIFICATION_COOLDOWN_HOURS
382+
/// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
383383
pub fn notify_liquidity_management_request(
384384
&self, client_id: PublicKey,
385385
) -> Result<(), LSPS5ProtocolError> {
@@ -394,13 +394,13 @@ where
394394
/// notification, signs it, and enqueues HTTP POSTs to each registered webhook.
395395
///
396396
/// This may fail if a similar notification was sent too recently,
397-
/// violating the notification cooldown period defined in [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`].
397+
/// violating the notification cooldown period defined in [`NOTIFICATION_COOLDOWN_TIME`].
398398
///
399399
/// # Parameters
400400
/// - `client_id`: the client's node-ID whose webhooks should be invoked.
401401
///
402402
/// [`WebhookNotificationMethod::LSPS5OnionMessageIncoming`]: super::msgs::WebhookNotificationMethod::LSPS5OnionMessageIncoming
403-
/// [`DEFAULT_NOTIFICATION_COOLDOWN_HOURS`]: super::service::DEFAULT_NOTIFICATION_COOLDOWN_HOURS
403+
/// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
404404
pub fn notify_onion_message_incoming(
405405
&self, client_id: PublicKey,
406406
) -> Result<(), LSPS5ProtocolError> {
@@ -429,7 +429,7 @@ where
429429
.last_notification_sent
430430
.get(&notification.method)
431431
.map(|last_sent| now.duration_since(&last_sent))
432-
.map_or(false, |duration| duration < DEFAULT_NOTIFICATION_COOLDOWN_HOURS)
432+
.map_or(false, |duration: Duration| duration < NOTIFICATION_COOLDOWN_TIME)
433433
});
434434

435435
if rate_limit_applies {

lightning-liquidity/tests/lsps5_integration_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use lightning_liquidity::lsps5::msgs::{
1919
WebhookNotificationMethod,
2020
};
2121
use lightning_liquidity::lsps5::service::{
22-
LSPS5ServiceConfig, DEFAULT_MAX_WEBHOOKS_PER_CLIENT, DEFAULT_NOTIFICATION_COOLDOWN_HOURS,
22+
LSPS5ServiceConfig, DEFAULT_MAX_WEBHOOKS_PER_CLIENT, NOTIFICATION_COOLDOWN_TIME,
2323
};
2424
use lightning_liquidity::lsps5::service::{
2525
MIN_WEBHOOK_RETENTION_DAYS, PRUNE_STALE_WEBHOOKS_INTERVAL_DAYS,
@@ -1119,7 +1119,7 @@ fn test_send_notifications_and_peer_connected_resets_cooldown() {
11191119
}
11201120

11211121
// 4. Advance time past cooldown and ensure payment_incoming can be sent again
1122-
mock_time_provider.advance_time(DEFAULT_NOTIFICATION_COOLDOWN_HOURS.as_secs() + 1);
1122+
mock_time_provider.advance_time(NOTIFICATION_COOLDOWN_TIME.as_secs() + 1);
11231123

11241124
let _ = service_handler.notify_payment_incoming(client_node_id);
11251125
let event = service_node.liquidity_manager.next_event().unwrap();

0 commit comments

Comments
 (0)