+ // Before returning any messages to send for the peer, this method will see if any messages were
+ // enqueued in the handler by users, find a path to the corresponding blinded path's introduction
+ // node, and then enqueue the message for sending to the first peer in the full path.
+ 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")
+ );
+ }
+