diff --git a/src/lib.rs b/src/lib.rs index ea17ffb661..4c39170999 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -651,6 +651,7 @@ impl Node { // First tick fires immediately; consume it so we don't run at t=0. pending_htlc_interval.tick().await; expiry_check_interval.tick().await; + let lm = liquidity_handler.liquidity_manager(); loop { tokio::select! { _ = stop_liquidity_handler.changed() => { @@ -666,7 +667,9 @@ impl Node { _ = expiry_check_interval.tick() => { liquidity_handler.handle_expired_htlcs().await; } - _ = liquidity_handler.handle_next_event() => {} + event = lm.next_event_async() => { + liquidity_handler.handle_event(event).await; + } } } }); diff --git a/src/liquidity.rs b/src/liquidity.rs index 986cca1bbc..83a0e70558 100644 --- a/src/liquidity.rs +++ b/src/liquidity.rs @@ -519,8 +519,12 @@ where } } - pub(crate) async fn handle_next_event(&self) { - match self.liquidity_manager.next_event_async().await { + /// Handles a single liquidity event. Must be called from a context that + /// guarantees the future runs to completion (e.g. a `select!` handler block), + /// since event processing includes `.await` points that are not + /// cancellation-safe. + pub(crate) async fn handle_event(&self, event: LiquidityEvent) { + match event { LiquidityEvent::LSPS1Client(LSPS1ClientEvent::SupportedOptionsReady { request_id, counterparty_node_id,