Skip to content

Commit 5430a09

Browse files
committed
3/3 Use MessageSendInstructions instead of PendingOnionMessage
Now that the `MessageRouter` can `create_blinded_paths` forcing callers of the `OnionMessenger` to provide it with a reply path up front is unnecessary complexity, doubly so in message handlers. Here we take the next step towards untangling that, moving from `PendingOnionMessage` to `MessageSendInstructions` for the outbound message queue in `AsyncPaymentsMessageHandler`. Better, we can also drop the `c_bindings`-specific message queue variant, unifying the APIs. Here we also drop `PendingOnionMessage` entirely. By unifying the response type with the outbound message queue type, this also fixes #3178.
1 parent db9c76a commit 5430a09

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

lightning/src/ln/channelmanager.rs

+2-2
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::{Destination, MessageRouter, PendingOnionMessage, Responder, MessageSendInstructions};
74+
use crate::onion_message::messenger::{Destination, MessageRouter, Responder, MessageSendInstructions};
7575
use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
7676
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
7777
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -10962,7 +10962,7 @@ where
1096210962

1096310963
fn release_held_htlc(&self, _message: ReleaseHeldHtlc) {}
1096410964

10965-
fn release_pending_messages(&self) -> Vec<PendingOnionMessage<AsyncPaymentsMessage>> {
10965+
fn release_pending_messages(&self) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)> {
1096610966
Vec::new()
1096710967
}
1096810968
}

lightning/src/onion_message/async_payments.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use crate::io;
1313
use crate::ln::msgs::DecodeError;
1414
#[cfg(not(c_bindings))]
15-
use crate::onion_message::messenger::PendingOnionMessage;
1615
use crate::onion_message::messenger::{Responder, MessageSendInstructions};
1716
use crate::onion_message::packet::OnionMessageContents;
1817
use crate::prelude::*;
@@ -40,23 +39,7 @@ pub trait AsyncPaymentsMessageHandler {
4039
///
4140
/// Typically, this is used for messages initiating an async payment flow rather than in response
4241
/// to another message.
43-
#[cfg(not(c_bindings))]
44-
fn release_pending_messages(&self) -> Vec<PendingOnionMessage<AsyncPaymentsMessage>> {
45-
vec![]
46-
}
47-
48-
/// Release any [`AsyncPaymentsMessage`]s that need to be sent.
49-
///
50-
/// Typically, this is used for messages initiating a payment flow rather than in response to
51-
/// another message.
52-
#[cfg(c_bindings)]
53-
fn release_pending_messages(
54-
&self,
55-
) -> Vec<(
56-
AsyncPaymentsMessage,
57-
crate::onion_message::messenger::Destination,
58-
Option<crate::blinded_path::message::BlindedMessagePath>,
59-
)> {
42+
fn release_pending_messages(&self) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)> {
6043
vec![]
6144
}
6245
}

lightning/src/onion_message/messenger.rs

-32
Original file line numberDiff line numberDiff line change
@@ -410,38 +410,6 @@ pub enum MessageSendInstructions {
410410
}
411411
}
412412

413-
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
414-
///
415-
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
416-
/// enqueued for sending.
417-
#[cfg(not(c_bindings))]
418-
pub struct PendingOnionMessage<T: OnionMessageContents> {
419-
/// The message contents to send in an [`OnionMessage`].
420-
pub contents: T,
421-
422-
/// The destination of the message.
423-
pub destination: Destination,
424-
425-
/// A reply path to include in the [`OnionMessage`] for a response.
426-
pub reply_path: Option<BlindedMessagePath>,
427-
}
428-
429-
#[cfg(c_bindings)]
430-
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
431-
///
432-
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
433-
/// enqueued for sending.
434-
pub type PendingOnionMessage<T> = (T, Destination, Option<BlindedMessagePath>);
435-
436-
pub(crate) fn new_pending_onion_message<T: OnionMessageContents>(
437-
contents: T, destination: Destination, reply_path: Option<BlindedMessagePath>
438-
) -> PendingOnionMessage<T> {
439-
#[cfg(not(c_bindings))]
440-
return PendingOnionMessage { contents, destination, reply_path };
441-
#[cfg(c_bindings)]
442-
return (contents, destination, reply_path);
443-
}
444-
445413
/// A trait defining behavior for routing an [`OnionMessage`].
446414
pub trait MessageRouter {
447415
/// Returns a route for sending an [`OnionMessage`] to the given [`Destination`].

0 commit comments

Comments
 (0)