Skip to content

Commit a24063a

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.
1 parent 2117c09 commit a24063a

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
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, ResponseInstruction, MessageSendInstructions};
74+
use crate::onion_message::messenger::{Destination, MessageRouter, Responder, ResponseInstruction, 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

+2-19
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
use crate::io;
1313
use crate::ln::msgs::DecodeError;
1414
#[cfg(not(c_bindings))]
15-
use crate::onion_message::messenger::PendingOnionMessage;
16-
use crate::onion_message::messenger::{Responder, ResponseInstruction};
15+
use crate::onion_message::messenger::{Responder, ResponseInstruction, MessageSendInstructions};
1716
use crate::onion_message::packet::OnionMessageContents;
1817
use crate::prelude::*;
1918
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
@@ -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
@@ -428,38 +428,6 @@ pub enum MessageSendInstructions {
428428
}
429429
}
430430

431-
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
432-
///
433-
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
434-
/// enqueued for sending.
435-
#[cfg(not(c_bindings))]
436-
pub struct PendingOnionMessage<T: OnionMessageContents> {
437-
/// The message contents to send in an [`OnionMessage`].
438-
pub contents: T,
439-
440-
/// The destination of the message.
441-
pub destination: Destination,
442-
443-
/// A reply path to include in the [`OnionMessage`] for a response.
444-
pub reply_path: Option<BlindedMessagePath>,
445-
}
446-
447-
#[cfg(c_bindings)]
448-
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
449-
///
450-
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
451-
/// enqueued for sending.
452-
pub type PendingOnionMessage<T> = (T, Destination, Option<BlindedMessagePath>);
453-
454-
pub(crate) fn new_pending_onion_message<T: OnionMessageContents>(
455-
contents: T, destination: Destination, reply_path: Option<BlindedMessagePath>
456-
) -> PendingOnionMessage<T> {
457-
#[cfg(not(c_bindings))]
458-
return PendingOnionMessage { contents, destination, reply_path };
459-
#[cfg(c_bindings)]
460-
return (contents, destination, reply_path);
461-
}
462-
463431
/// A trait defining behavior for routing an [`OnionMessage`].
464432
pub trait MessageRouter {
465433
/// Returns a route for sending an [`OnionMessage`] to the given [`Destination`].

0 commit comments

Comments
 (0)