Skip to content

Commit 63cb7b2

Browse files
fixup: on lsps1, don't count pending_requests as an active flow.
the service has not responded yet, so don't count that for DoS protection purposes
1 parent b522194 commit 63cb7b2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lightning-liquidity/src/lsps1/service.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,18 @@ where
174174
&self.config
175175
}
176176

177+
/// Returns whether the peer currently has any active LSPS1 order flows.
178+
///
179+
/// An order is considered active only after we have validated the client's
180+
/// `CreateOrder` request and replied with a `CreateOrder` response containing
181+
/// an `order_id`.
182+
/// Pending requests that are still awaiting our response are deliberately NOT counted.
177183
pub(crate) fn has_active_requests(&self, counterparty_node_id: &PublicKey) -> bool {
178184
let outer_state_lock = self.per_peer_state.read().unwrap();
179-
outer_state_lock.get(counterparty_node_id).map_or(false, |inner| {
180-
let peer_state = inner.lock().unwrap();
181-
!(peer_state.pending_requests.is_empty()
182-
&& peer_state.outbound_channels_by_order_id.is_empty())
183-
})
185+
outer_state_lock.get(counterparty_node_id).map_or(false, |inner| {
186+
let peer_state = inner.lock().unwrap();
187+
!peer_state.outbound_channels_by_order_id.is_empty()
188+
})
184189
}
185190

186191
fn handle_get_info_request(

0 commit comments

Comments
 (0)