|
84 | 84 | ///
|
85 | 85 | /// [`SupportedOptionsReady`]: crate::lsps1::event::LSPS1ClientEvent::SupportedOptionsReady
|
86 | 86 | pub fn request_supported_options(&self, counterparty_node_id: PublicKey) -> RequestId {
|
| 87 | + let _msg_queue_notifier = self.pending_messages.notifier(); |
87 | 88 | let request_id = crate::utils::generate_request_id(&self.entropy_source);
|
88 | 89 | {
|
89 | 90 | let mut outer_state_lock = self.per_peer_state.write().unwrap();
|
@@ -191,25 +192,19 @@ where
|
191 | 192 | &self, counterparty_node_id: &PublicKey, order: OrderParameters,
|
192 | 193 | refund_onchain_address: Option<Address>,
|
193 | 194 | ) -> RequestId {
|
194 |
| - let (request_id, request_msg) = { |
195 |
| - let mut outer_state_lock = self.per_peer_state.write().unwrap(); |
196 |
| - let inner_state_lock = outer_state_lock |
197 |
| - .entry(*counterparty_node_id) |
198 |
| - .or_insert(Mutex::new(PeerState::default())); |
199 |
| - let mut peer_state_lock = inner_state_lock.lock().unwrap(); |
200 |
| - |
201 |
| - let request_id = crate::utils::generate_request_id(&self.entropy_source); |
202 |
| - let request = |
203 |
| - LSPS1Request::CreateOrder(CreateOrderRequest { order, refund_onchain_address }); |
204 |
| - let msg = LSPS1Message::Request(request_id.clone(), request).into(); |
205 |
| - peer_state_lock.pending_create_order_requests.insert(request_id.clone()); |
| 195 | + let _msg_queue_notifier = self.pending_messages.notifier(); |
| 196 | + let mut outer_state_lock = self.per_peer_state.write().unwrap(); |
| 197 | + let inner_state_lock = outer_state_lock |
| 198 | + .entry(*counterparty_node_id) |
| 199 | + .or_insert(Mutex::new(PeerState::default())); |
| 200 | + let mut peer_state_lock = inner_state_lock.lock().unwrap(); |
206 | 201 |
|
207 |
| - (request_id, Some(msg)) |
208 |
| - }; |
209 |
| - |
210 |
| - if let Some(msg) = request_msg { |
211 |
| - self.pending_messages.enqueue(&counterparty_node_id, msg); |
212 |
| - } |
| 202 | + let request_id = crate::utils::generate_request_id(&self.entropy_source); |
| 203 | + let request = |
| 204 | + LSPS1Request::CreateOrder(CreateOrderRequest { order, refund_onchain_address }); |
| 205 | + let msg = LSPS1Message::Request(request_id.clone(), request).into(); |
| 206 | + self.pending_messages.enqueue(&counterparty_node_id, msg); |
| 207 | + peer_state_lock.pending_create_order_requests.insert(request_id.clone()); |
213 | 208 |
|
214 | 209 | request_id
|
215 | 210 | }
|
@@ -310,25 +305,19 @@ where
|
310 | 305 | pub fn check_order_status(
|
311 | 306 | &self, counterparty_node_id: &PublicKey, order_id: OrderId,
|
312 | 307 | ) -> RequestId {
|
313 |
| - let (request_id, request_msg) = { |
314 |
| - let mut outer_state_lock = self.per_peer_state.write().unwrap(); |
315 |
| - let inner_state_lock = outer_state_lock |
316 |
| - .entry(*counterparty_node_id) |
317 |
| - .or_insert(Mutex::new(PeerState::default())); |
318 |
| - let mut peer_state_lock = inner_state_lock.lock().unwrap(); |
319 |
| - |
320 |
| - let request_id = crate::utils::generate_request_id(&self.entropy_source); |
321 |
| - peer_state_lock.pending_get_order_requests.insert(request_id.clone()); |
| 308 | + let _msg_queue_notifier = self.pending_messages.notifier(); |
| 309 | + let mut outer_state_lock = self.per_peer_state.write().unwrap(); |
| 310 | + let inner_state_lock = outer_state_lock |
| 311 | + .entry(*counterparty_node_id) |
| 312 | + .or_insert(Mutex::new(PeerState::default())); |
| 313 | + let mut peer_state_lock = inner_state_lock.lock().unwrap(); |
322 | 314 |
|
323 |
| - let request = LSPS1Request::GetOrder(GetOrderRequest { order_id: order_id.clone() }); |
324 |
| - let msg = LSPS1Message::Request(request_id.clone(), request).into(); |
325 |
| - |
326 |
| - (request_id, Some(msg)) |
327 |
| - }; |
| 315 | + let request_id = crate::utils::generate_request_id(&self.entropy_source); |
| 316 | + peer_state_lock.pending_get_order_requests.insert(request_id.clone()); |
328 | 317 |
|
329 |
| - if let Some(msg) = request_msg { |
330 |
| - self.pending_messages.enqueue(&counterparty_node_id, msg); |
331 |
| - } |
| 318 | + let request = LSPS1Request::GetOrder(GetOrderRequest { order_id: order_id.clone() }); |
| 319 | + let msg = LSPS1Message::Request(request_id.clone(), request).into(); |
| 320 | + self.pending_messages.enqueue(&counterparty_node_id, msg); |
332 | 321 |
|
333 | 322 | request_id
|
334 | 323 | }
|
|
0 commit comments