Skip to content

Commit 069ee2a

Browse files
committed
Remove path_id from Responder, and OnionMessageResponse struct
1. The path_id will be removed from the codebase in the following commits.
1 parent 88e1b56 commit 069ee2a

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

fuzz/src/onion_message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ mod tests {
341341
"Received an onion message with path_id None and a reply_path: Custom(TestCustomMessage)"
342342
.to_string())), Some(&1));
343343
assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
344-
"Constructing onion message when responding with Custom Message to an onion message with path_id None: TestCustomMessage".to_string())), Some(&1));
344+
"Constructing onion message when responding with Custom Message to an onion message: TestCustomMessage".to_string())), Some(&1));
345345
assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
346-
"Buffered onion message when responding with Custom Message to an onion message with path_id None".to_string())), Some(&1));
346+
"Buffered onion message when responding with Custom Message to an onion message".to_string())), Some(&1));
347347
}
348348

349349
let two_unblinded_hops_om = "\

lightning/src/onion_message/functional_tests.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,13 @@ fn async_response_over_one_blinded_hop() {
427427

428428
// 2. Define the message sent from Bob to Alice.
429429
let message = TestCustomMessage::Ping;
430-
let path_id = Some([2; 32]);
431430

432431
// 3. Simulate the creation of a Blinded Reply path provided by Bob.
433432
let secp_ctx = Secp256k1::new();
434433
let reply_path = BlindedPath::new_for_message(&[], nodes[1].node_id, &*nodes[1].entropy_source, &secp_ctx).unwrap();
435434

436435
// 4. Create a responder using the reply path for Alice.
437-
let responder = Some(Responder::new(reply_path, path_id));
436+
let responder = Some(Responder::new(reply_path));
438437

439438
// 5. Expect Alice to receive the message and create a response instruction for it.
440439
alice.custom_message_handler.expect_message(message.clone());
@@ -466,11 +465,10 @@ fn async_response_with_reply_path_succeeds() {
466465

467466
// Alice receives a message from Bob with an added reply_path for responding back.
468467
let message = TestCustomMessage::Ping;
469-
let path_id = Some([2; 32]);
470468
let reply_path = BlindedPath::new_for_message(&[], bob.node_id, &*bob.entropy_source, &secp_ctx).unwrap();
471469

472470
// Alice asynchronously responds to Bob, expecting a response back from him.
473-
let responder = Responder::new(reply_path, path_id);
471+
let responder = Responder::new(reply_path);
474472
alice.custom_message_handler.expect_message_and_response(message.clone());
475473
let response_instruction = alice.custom_message_handler.handle_custom_message(message, Some(responder));
476474

@@ -503,13 +501,12 @@ fn async_response_with_reply_path_fails() {
503501

504502
// Alice receives a message from Bob with an added reply_path for responding back.
505503
let message = TestCustomMessage::Ping;
506-
let path_id = Some([2; 32]);
507504
let reply_path = BlindedPath::new_for_message(&[], bob.node_id, &*bob.entropy_source, &secp_ctx).unwrap();
508505

509506
// Alice tries to asynchronously respond to Bob, but fails because the nodes are unannounced and
510507
// disconnected. Thus, a reply path could no be created for the response.
511508
disconnect_peers(alice, bob);
512-
let responder = Responder::new(reply_path, path_id);
509+
let responder = Responder::new(reply_path);
513510
alice.custom_message_handler.expect_message_and_response(message.clone());
514511
let response_instruction = alice.custom_message_handler.handle_custom_message(message, Some(responder));
515512

lightning/src/onion_message/messenger.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,17 @@ impl OnionMessageRecipient {
344344
pub struct Responder {
345345
/// The path along which a response can be sent.
346346
reply_path: BlindedPath,
347-
path_id: Option<[u8; 32]>
348347
}
349348

350349
impl_writeable_tlv_based!(Responder, {
351350
(0, reply_path, required),
352-
(2, path_id, option),
353351
});
354352

355353
impl Responder {
356354
/// Creates a new [`Responder`] instance with the provided reply path.
357-
pub(super) fn new(reply_path: BlindedPath, path_id: Option<[u8; 32]>) -> Self {
355+
pub(super) fn new(reply_path: BlindedPath) -> Self {
358356
Responder {
359357
reply_path,
360-
path_id,
361358
}
362359
}
363360

@@ -368,7 +365,6 @@ impl Responder {
368365
ResponseInstruction::WithoutReplyPath(OnionMessageResponse {
369366
message: response,
370367
reply_path: self.reply_path,
371-
path_id: self.path_id,
372368
})
373369
}
374370

@@ -379,7 +375,6 @@ impl Responder {
379375
ResponseInstruction::WithReplyPath(OnionMessageResponse {
380376
message: response,
381377
reply_path: self.reply_path,
382-
path_id: self.path_id,
383378
})
384379
}
385380
}
@@ -388,7 +383,6 @@ impl Responder {
388383
pub struct OnionMessageResponse<T: OnionMessageContents> {
389384
message: T,
390385
reply_path: BlindedPath,
391-
path_id: Option<[u8; 32]>,
392386
}
393387

394388
/// `ResponseInstruction` represents instructions for responding to received messages.
@@ -1272,9 +1266,8 @@ where
12721266
Err(err) => {
12731267
log_trace!(
12741268
self.logger,
1275-
"Failed to create reply path when responding with {} to an onion message \
1276-
with path_id {:02x?}: {:?}",
1277-
message_type, response.path_id, err
1269+
"Failed to create reply path when responding with {} to an onion message: {:?}",
1270+
message_type, err
12781271
);
12791272
return Err(err);
12801273
}
@@ -1284,9 +1277,8 @@ where
12841277
self.find_path_and_enqueue_onion_message(
12851278
response.message, Destination::BlindedPath(response.reply_path), reply_path,
12861279
format_args!(
1287-
"when responding with {} to an onion message with path_id {:02x?}",
1280+
"when responding with {} to an onion message",
12881281
message_type,
1289-
response.path_id
12901282
)
12911283
).map(|result| Some(result))
12921284
}
@@ -1446,9 +1438,7 @@ where
14461438
"Received an onion message with path_id {:02x?} and {} reply_path: {:?}",
14471439
path_id, if reply_path.is_some() { "a" } else { "no" }, message);
14481440

1449-
let responder = reply_path.map(
1450-
|reply_path| Responder::new(reply_path, path_id)
1451-
);
1441+
let responder = reply_path.map(Responder::new);
14521442
match message {
14531443
ParsedOnionMessageContents::Offers(msg) => {
14541444
let response_instructions = self.offers_handler.handle_message(msg, responder);

0 commit comments

Comments
 (0)