assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
"Received an onion message with path_id None and a reply_path".to_string())), Some(&1));
assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
- "Responding to onion message with path_id None".to_string())), Some(&1));
+ "Sending onion message when responding to onion message with path_id None".to_string())), Some(&1));
assert_eq!(log_entries.get(&("lightning::onion_message::messenger".to_string(),
- "Failed responding to onion message with path_id None: TooFewBlindedHops".to_string())), Some(&1));
+ "Failed sending onion message when responding to onion message with path_id None: TooFewBlindedHops".to_string())), Some(&1));
}
let two_unblinded_hops_om = "020000000000000000000000000000000000000000000000000000000000000e01055600020000000000000000000000000000000000000000000000000000000000000e0135043304210202020202020202020202020202020202020202020202020202020202020202026d000000000000000000000000000000eb0000000000000000000000000000000000000000000000000000000000000036041096000000000000000000000000000000fd1092202a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004800000000000000000000000000000000000000000000000000000000000000";
use crate::util::logger::Logger;
use crate::util::ser::Writeable;
+use core::fmt;
use core::ops::Deref;
use crate::io;
use crate::sync::{Arc, Mutex};
}
}
- fn respond_with_onion_message<T: CustomOnionMessageContents>(
- &self, response: OnionMessageContents<T>, path_id: Option<[u8; 32]>,
- reply_path: Option<BlindedPath>
+ fn find_path_and_enqueue_onion_message<T: CustomOnionMessageContents>(
+ &self, contents: OnionMessageContents<T>, destination: Destination,
+ log_suffix: fmt::Arguments
) {
let sender = match self.node_signer.get_node_id(Recipient::Node) {
Ok(node_id) => node_id,
Err(_) => {
- log_warn!(
- self.logger, "Unable to retrieve node id when responding to onion message with \
- path_id {:02x?}", path_id
- );
+ log_warn!(self.logger, "Unable to retrieve node id {}", log_suffix);
return;
}
};
let peers = self.pending_messages.lock().unwrap().keys().copied().collect();
-
- let destination = match reply_path {
- Some(reply_path) => Destination::BlindedPath(reply_path),
- None => {
- log_trace!(
- self.logger, "Missing reply path when responding to onion message with path_id \
- {:02x?}", path_id
- );
- return;
- },
- };
-
let path = match self.message_router.find_path(sender, peers, destination) {
Ok(path) => path,
Err(()) => {
- log_trace!(
- self.logger, "Failed to find path when responding to onion message with \
- path_id {:02x?}", path_id
- );
+ log_trace!(self.logger, "Failed to find path {}", log_suffix);
return;
},
};
- log_trace!(self.logger, "Responding to onion message with path_id {:02x?}", path_id);
+ log_trace!(self.logger, "Sending onion message {}", log_suffix);
- if let Err(e) = self.send_onion_message(path, response, None) {
- log_trace!(
- self.logger, "Failed responding to onion message with path_id {:02x?}: {:?}",
- path_id, e
- );
+ if let Err(e) = self.send_onion_message(path, contents, None) {
+ log_trace!(self.logger, "Failed sending onion message {}: {:?}", log_suffix, e);
return;
}
}
},
};
if let Some(response) = response {
- self.respond_with_onion_message(response, path_id, reply_path);
+ match reply_path {
+ Some(reply_path) => {
+ self.find_path_and_enqueue_onion_message(
+ response, Destination::BlindedPath(reply_path), format_args!(
+ "when responding to onion message with path_id {:02x?}", path_id
+ )
+ );
+ },
+ None => {
+ log_trace!(
+ self.logger,
+ "Missing reply path when responding to onion message with path_id {:02x?}",
+ path_id
+ );
+ },
+ }
}
},
Ok(PeeledOnion::Forward(next_node_id, onion_message)) => {