Skip to content

Commit 1ee0a67

Browse files
committed
Rename ResponseInstruction -> MessageSendInstructions
In a coming commit we'll start using `ResponseInstruction` for all messages, so it no longer makes sense to continue calling it `Response`.
1 parent 81fe5d8 commit 1ee0a67

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use crate::offers::parse::Bolt12SemanticError;
7171
use crate::offers::refund::{Refund, RefundBuilder};
7272
use crate::offers::signer;
7373
use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
74-
use crate::onion_message::messenger::{new_pending_onion_message, Destination, MessageRouter, PendingOnionMessage, Responder, ResponseInstruction};
74+
use crate::onion_message::messenger::{new_pending_onion_message, Destination, MessageRouter, PendingOnionMessage, Responder, MessageSendInstructions};
7575
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
7676
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
7777
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -10749,7 +10749,7 @@ where
1074910749
{
1075010750
fn handle_message(
1075110751
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
10752-
) -> Option<(OffersMessage, ResponseInstruction)> {
10752+
) -> Option<(OffersMessage, MessageSendInstructions)> {
1075310753
let secp_ctx = &self.secp_ctx;
1075410754
let expanded_key = &self.inbound_payment_key;
1075510755

@@ -10956,7 +10956,7 @@ where
1095610956
{
1095710957
fn held_htlc_available(
1095810958
&self, _message: HeldHtlcAvailable, _responder: Option<Responder>
10959-
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
10959+
) -> Option<(ReleaseHeldHtlc, MessageSendInstructions)> {
1096010960
None
1096110961
}
1096210962

lightning/src/ln/peer_handler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor, NextNoiseStep, Mes
3030
use crate::ln::wire;
3131
use crate::ln::wire::{Encode, Type};
3232
use crate::onion_message::async_payments::{AsyncPaymentsMessageHandler, HeldHtlcAvailable, ReleaseHeldHtlc};
33-
use crate::onion_message::messenger::{CustomOnionMessageHandler, PendingOnionMessage, Responder, ResponseInstruction};
33+
use crate::onion_message::messenger::{CustomOnionMessageHandler, PendingOnionMessage, Responder, MessageSendInstructions};
3434
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
3535
use crate::onion_message::packet::OnionMessageContents;
3636
use crate::routing::gossip::{NodeId, NodeAlias};
@@ -144,21 +144,21 @@ impl OnionMessageHandler for IgnoringMessageHandler {
144144
}
145145

146146
impl OffersMessageHandler for IgnoringMessageHandler {
147-
fn handle_message(&self, _message: OffersMessage, _context: Option<OffersContext>, _responder: Option<Responder>) -> Option<(OffersMessage, ResponseInstruction)> {
147+
fn handle_message(&self, _message: OffersMessage, _context: Option<OffersContext>, _responder: Option<Responder>) -> Option<(OffersMessage, MessageSendInstructions)> {
148148
None
149149
}
150150
}
151151
impl AsyncPaymentsMessageHandler for IgnoringMessageHandler {
152152
fn held_htlc_available(
153153
&self, _message: HeldHtlcAvailable, _responder: Option<Responder>,
154-
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
154+
) -> Option<(ReleaseHeldHtlc, MessageSendInstructions)> {
155155
None
156156
}
157157
fn release_held_htlc(&self, _message: ReleaseHeldHtlc) {}
158158
}
159159
impl CustomOnionMessageHandler for IgnoringMessageHandler {
160160
type CustomMessage = Infallible;
161-
fn handle_custom_message(&self, _message: Self::CustomMessage, _context: Option<Vec<u8>>, _responder: Option<Responder>) -> Option<(Infallible, ResponseInstruction)> {
161+
fn handle_custom_message(&self, _message: Self::CustomMessage, _context: Option<Vec<u8>>, _responder: Option<Responder>) -> Option<(Infallible, MessageSendInstructions)> {
162162
// Since we always return `None` in the read the handle method should never be called.
163163
unreachable!();
164164
}

lightning/src/onion_message/async_payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::io;
1313
use crate::ln::msgs::DecodeError;
1414
#[cfg(not(c_bindings))]
1515
use crate::onion_message::messenger::PendingOnionMessage;
16-
use crate::onion_message::messenger::{Responder, ResponseInstruction};
16+
use crate::onion_message::messenger::{Responder, MessageSendInstructions};
1717
use crate::onion_message::packet::OnionMessageContents;
1818
use crate::prelude::*;
1919
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
@@ -30,7 +30,7 @@ pub trait AsyncPaymentsMessageHandler {
3030
/// the held funds.
3131
fn held_htlc_available(
3232
&self, message: HeldHtlcAvailable, responder: Option<Responder>,
33-
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)>;
33+
) -> Option<(ReleaseHeldHtlc, MessageSendInstructions)>;
3434

3535
/// Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC
3636
/// should be released to the corresponding payee.

lightning/src/onion_message/functional_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::sign::{NodeSigner, Recipient};
2020
use crate::util::ser::{FixedLengthReader, LengthReadable, Writeable, Writer};
2121
use crate::util::test_utils;
2222
use super::async_payments::{AsyncPaymentsMessageHandler, HeldHtlcAvailable, ReleaseHeldHtlc};
23-
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, ResponseInstruction, SendError, SendSuccess};
23+
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, MessageSendInstructions, SendError, SendSuccess};
2424
use super::offers::{OffersMessage, OffersMessageHandler};
2525
use super::packet::{OnionMessageContents, Packet};
2626

@@ -76,7 +76,7 @@ impl Drop for MessengerNode {
7676
struct TestOffersMessageHandler {}
7777

7878
impl OffersMessageHandler for TestOffersMessageHandler {
79-
fn handle_message(&self, _message: OffersMessage, _context: Option<OffersContext>, _responder: Option<Responder>) -> Option<(OffersMessage, ResponseInstruction)> {
79+
fn handle_message(&self, _message: OffersMessage, _context: Option<OffersContext>, _responder: Option<Responder>) -> Option<(OffersMessage, MessageSendInstructions)> {
8080
None
8181
}
8282
}
@@ -86,7 +86,7 @@ struct TestAsyncPaymentsMessageHandler {}
8686
impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler {
8787
fn held_htlc_available(
8888
&self, _message: HeldHtlcAvailable, _responder: Option<Responder>,
89-
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
89+
) -> Option<(ReleaseHeldHtlc, MessageSendInstructions)> {
9090
None
9191
}
9292
fn release_held_htlc(&self, _message: ReleaseHeldHtlc) {}
@@ -174,7 +174,7 @@ impl Drop for TestCustomMessageHandler {
174174

175175
impl CustomOnionMessageHandler for TestCustomMessageHandler {
176176
type CustomMessage = TestCustomMessage;
177-
fn handle_custom_message(&self, msg: Self::CustomMessage, context: Option<Vec<u8>>, responder: Option<Responder>) -> Option<(Self::CustomMessage, ResponseInstruction)> {
177+
fn handle_custom_message(&self, msg: Self::CustomMessage, context: Option<Vec<u8>>, responder: Option<Responder>) -> Option<(Self::CustomMessage, MessageSendInstructions)> {
178178
let expectation = self.get_next_expectation();
179179
assert_eq!(msg, expectation.expect);
180180

lightning/src/onion_message/messenger.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl OnionMessageRecipient {
342342
}
343343

344344

345-
/// The `Responder` struct creates an appropriate [`ResponseInstruction`]
345+
/// The `Responder` struct creates an appropriate [`MessageSendInstructions`]
346346
/// for responding to a message.
347347
#[derive(Clone, Debug, Eq, PartialEq)]
348348
pub struct Responder {
@@ -362,42 +362,42 @@ impl Responder {
362362
}
363363
}
364364

365-
/// Creates a [`ResponseInstruction::WithoutReplyPath`] for a given response.
365+
/// Creates a [`MessageSendInstructions::WithoutReplyPath`] for a given response.
366366
///
367367
/// Use when the recipient doesn't need to send back a reply to us.
368-
pub fn respond<T: OnionMessageContents>(self, response: T) -> Option<(T, ResponseInstruction)> {
369-
Some((response, ResponseInstruction::WithoutReplyPath {
368+
pub fn respond<T: OnionMessageContents>(self, response: T) -> Option<(T, MessageSendInstructions)> {
369+
Some((response, MessageSendInstructions::WithoutReplyPath {
370370
send_path: self.reply_path,
371371
}))
372372
}
373373

374-
/// Creates a [`ResponseInstruction::WithReplyPath`] for a given response.
374+
/// Creates a [`MessageSendInstructions::WithReplyPath`] for a given response.
375375
///
376376
/// Use when the recipient needs to send back a reply to us.
377-
pub fn respond_with_reply_path<T: OnionMessageContents>(self, response: T, context: MessageContext) -> Option<(T, ResponseInstruction)> {
378-
Some((response, ResponseInstruction::WithReplyPath {
377+
pub fn respond_with_reply_path<T: OnionMessageContents>(self, response: T, context: MessageContext) -> Option<(T, MessageSendInstructions)> {
378+
Some((response, MessageSendInstructions::WithReplyPath {
379379
send_path: self.reply_path,
380380
context: context,
381381
}))
382382
}
383383
}
384384

385-
/// `ResponseInstruction` represents instructions for responding to received messages.
385+
/// Instructions for how and where to send a message.
386386
#[derive(Clone)]
387-
pub enum ResponseInstruction {
388-
/// Indicates that a response should be sent including a reply path for
389-
/// the recipient to respond back.
387+
pub enum MessageSendInstructions {
388+
/// Indicates that a message should be sent including a reply path for the recipient to
389+
/// respond.
390390
WithReplyPath {
391-
/// The path over which we'll send our reply.
391+
/// The desination where we need to send our message.
392392
send_path: BlindedMessagePath,
393393
/// The context to include in the reply path we'll give the recipient so they can respond
394394
/// to us.
395395
context: MessageContext,
396396
},
397-
/// Indicates that a response should be sent without including a reply path
398-
/// for the recipient to respond back.
397+
/// Indicates that a emssage should be sent without including a reply path, preventing the
398+
/// recipient from responding.
399399
WithoutReplyPath {
400-
/// The path over which we'll send our reply.
400+
/// The desination where we need to send our message.
401401
send_path: BlindedMessagePath,
402402
}
403403
}
@@ -802,7 +802,7 @@ pub trait CustomOnionMessageHandler {
802802
/// The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`].
803803
fn handle_custom_message(
804804
&self, message: Self::CustomMessage, context: Option<Vec<u8>>, responder: Option<Responder>
805-
) -> Option<(Self::CustomMessage, ResponseInstruction)>;
805+
) -> Option<(Self::CustomMessage, MessageSendInstructions)>;
806806

807807
/// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the
808808
/// message type is unknown.
@@ -1313,7 +1313,7 @@ where
13131313
)
13141314
}
13151315

1316-
/// Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`],
1316+
/// Handles the response to an [`OnionMessage`] based on its [`MessageSendInstructions`],
13171317
/// enqueueing any response for sending.
13181318
///
13191319
/// This function is useful for asynchronous handling of [`OnionMessage`]s.
@@ -1322,11 +1322,11 @@ where
13221322
/// generating the response asynchronously. Subsequently, when the response is prepared and
13231323
/// ready for sending, that task can invoke this method to enqueue the response for delivery.
13241324
pub fn handle_onion_message_response<T: OnionMessageContents>(
1325-
&self, response_message: T, response: ResponseInstruction,
1325+
&self, response_message: T, response: MessageSendInstructions,
13261326
) -> Result<Option<SendSuccess>, SendError> {
13271327
let (response_path, context) = match response {
1328-
ResponseInstruction::WithReplyPath { send_path, context } => (send_path, Some(context)),
1329-
ResponseInstruction::WithoutReplyPath { send_path } => (send_path, None),
1328+
MessageSendInstructions::WithReplyPath { send_path, context } => (send_path, Some(context)),
1329+
MessageSendInstructions::WithoutReplyPath { send_path } => (send_path, None),
13301330
};
13311331

13321332
let message_type = response_message.msg_type();

lightning/src/onion_message/offers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::offers::static_invoice::StaticInvoice;
2222
use crate::onion_message::packet::OnionMessageContents;
2323
use crate::util::logger::Logger;
2424
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
25-
use crate::onion_message::messenger::{ResponseInstruction, Responder};
25+
use crate::onion_message::messenger::{MessageSendInstructions, Responder};
2626
#[cfg(not(c_bindings))]
2727
use crate::onion_message::messenger::PendingOnionMessage;
2828

@@ -47,7 +47,7 @@ pub trait OffersMessageHandler {
4747
/// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
4848
fn handle_message(
4949
&self, message: OffersMessage, context: Option<OffersContext>, responder: Option<Responder>,
50-
) -> Option<(OffersMessage, ResponseInstruction)>;
50+
) -> Option<(OffersMessage, MessageSendInstructions)>;
5151

5252
/// Releases any [`OffersMessage`]s that need to be sent.
5353
///

0 commit comments

Comments
 (0)