From 691e10f01eb904804a6a33d8cec8fc6568b0a884 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Thu, 6 Jun 2024 11:56:37 -0400 Subject: [PATCH] DRY responder instantiation for onion messages. --- lightning/src/onion_message/messenger.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 2e47e7c84..4182fdf03 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -1436,18 +1436,15 @@ where "Received an onion message with path_id {:02x?} and {} reply_path: {:?}", path_id, if reply_path.is_some() { "a" } else { "no" }, message); + let responder = reply_path.map( + |reply_path| Responder::new(reply_path, path_id) + ); match message { ParsedOnionMessageContents::Offers(msg) => { - let responder = reply_path.map( - |reply_path| Responder::new(reply_path, path_id) - ); let response_instructions = self.offers_handler.handle_message(msg, responder); let _ = self.handle_onion_message_response(response_instructions); }, ParsedOnionMessageContents::AsyncPayments(AsyncPaymentsMessage::HeldHtlcAvailable(msg)) => { - let responder = reply_path.map( - |reply_path| Responder::new(reply_path, path_id) - ); let response_instructions = self.async_payments_handler.held_htlc_available( msg, responder ); @@ -1457,9 +1454,6 @@ where self.async_payments_handler.release_held_htlc(msg); }, ParsedOnionMessageContents::Custom(msg) => { - let responder = reply_path.map( - |reply_path| Responder::new(reply_path, path_id) - ); let response_instructions = self.custom_handler.handle_custom_message(msg, responder); let _ = self.handle_onion_message_response(response_instructions); }, -- 2.39.5