-
Notifications
You must be signed in to change notification settings - Fork 412
Small bindings tweaks for 0.0.118 #2679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,7 @@ where | |
/// | ||
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are | ||
/// enqueued for sending. | ||
#[cfg(not(c_bindings))] | ||
pub struct PendingOnionMessage<T: OnionMessageContents> { | ||
/// The message contents to send in an [`OnionMessage`]. | ||
pub contents: T, | ||
|
@@ -170,6 +171,22 @@ pub struct PendingOnionMessage<T: OnionMessageContents> { | |
pub reply_path: Option<BlindedPath>, | ||
} | ||
|
||
#[cfg(c_bindings)] | ||
/// An [`OnionMessage`] for [`OnionMessenger`] to send. | ||
/// | ||
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are | ||
/// enqueued for sending. | ||
pub type PendingOnionMessage<T: OnionMessageContents> = (T, Destination, Option<BlindedPath>); | ||
|
||
pub(crate) fn new_pending_onion_message<T: OnionMessageContents>( | ||
contents: T, destination: Destination, reply_path: Option<BlindedPath> | ||
) -> PendingOnionMessage<T> { | ||
#[cfg(not(c_bindings))] | ||
return PendingOnionMessage { contents, destination, reply_path }; | ||
#[cfg(c_bindings)] | ||
return (contents, destination, reply_path); | ||
} | ||
|
||
/// A trait defining behavior for routing an [`OnionMessage`]. | ||
pub trait MessageRouter { | ||
/// Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. | ||
|
@@ -286,7 +303,15 @@ pub trait CustomOnionMessageHandler { | |
/// | ||
/// Typically, this is used for messages initiating a message flow rather than in response to | ||
/// another message. The latter should use the return value of [`Self::handle_custom_message`]. | ||
#[cfg(not(c_bindings))] | ||
fn release_pending_custom_messages(&self) -> Vec<PendingOnionMessage<Self::CustomMessage>>; | ||
|
||
/// Releases any [`Self::CustomMessage`]s that need to be sent. | ||
/// | ||
/// Typically, this is used for messages initiating a message flow rather than in response to | ||
/// another message. The latter should use the return value of [`Self::handle_custom_message`]. | ||
#[cfg(c_bindings)] | ||
fn release_pending_custom_messages(&self) -> Vec<(Self::CustomMessage, Destination, Option<BlindedPath>)>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to change if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, that is the first thing I tried and it didn't really work. Type aliases in bindings are handled a bit specifically for cases we rely on (eg the scorer), so it didn't quite work here. I will drop it to not be pub. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, reverted this. onion_messages/mod.rs re-exports it as |
||
} | ||
|
||
/// A processed incoming onion message, containing either a Forward (another onion message) | ||
|
@@ -686,15 +711,21 @@ where | |
fn next_onion_message_for_peer(&self, peer_node_id: PublicKey) -> Option<OnionMessage> { | ||
// Enqueue any initiating `OffersMessage`s to send. | ||
for message in self.offers_handler.release_pending_messages() { | ||
#[cfg(not(c_bindings))] | ||
let PendingOnionMessage { contents, destination, reply_path } = message; | ||
#[cfg(c_bindings)] | ||
let (contents, destination, reply_path) = message; | ||
self.find_path_and_enqueue_onion_message( | ||
contents, destination, reply_path, format_args!("when sending OffersMessage") | ||
); | ||
} | ||
|
||
// Enqueue any initiating `CustomMessage`s to send. | ||
for message in self.custom_handler.release_pending_custom_messages() { | ||
#[cfg(not(c_bindings))] | ||
let PendingOnionMessage { contents, destination, reply_path } = message; | ||
#[cfg(c_bindings)] | ||
let (contents, destination, reply_path) = message; | ||
self.find_path_and_enqueue_onion_message( | ||
contents, destination, reply_path, format_args!("when sending CustomMessage") | ||
); | ||
|
Uh oh!
There was an error while loading. Please reload this page.