Skip to content

Commit 4ad229e

Browse files
DRY responder instantiation for onion messages.
1 parent a5e378b commit 4ad229e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lightning/src/onion_message/messenger.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1436,18 +1436,15 @@ where
14361436
"Received an onion message with path_id {:02x?} and {} reply_path: {:?}",
14371437
path_id, if reply_path.is_some() { "a" } else { "no" }, message);
14381438

1439+
let responder = reply_path.map(
1440+
|reply_path| Responder::new(reply_path, path_id)
1441+
);
14391442
match message {
14401443
ParsedOnionMessageContents::Offers(msg) => {
1441-
let responder = reply_path.map(
1442-
|reply_path| Responder::new(reply_path, path_id)
1443-
);
14441444
let response_instructions = self.offers_handler.handle_message(msg, responder);
14451445
let _ = self.handle_onion_message_response(response_instructions);
14461446
},
14471447
ParsedOnionMessageContents::AsyncPayments(AsyncPaymentsMessage::HeldHtlcAvailable(msg)) => {
1448-
let responder = reply_path.map(
1449-
|reply_path| Responder::new(reply_path, path_id)
1450-
);
14511448
let response_instructions = self.async_payments_handler.held_htlc_available(
14521449
msg, responder
14531450
);
@@ -1457,9 +1454,6 @@ where
14571454
self.async_payments_handler.release_held_htlc(msg);
14581455
},
14591456
ParsedOnionMessageContents::Custom(msg) => {
1460-
let responder = reply_path.map(
1461-
|reply_path| Responder::new(reply_path, path_id)
1462-
);
14631457
let response_instructions = self.custom_handler.handle_custom_message(msg, responder);
14641458
let _ = self.handle_onion_message_response(response_instructions);
14651459
},

0 commit comments

Comments
 (0)