Skip to content

Commit b78cb69

Browse files
committed
Avoid overloading introduction_node_id
1 parent 86e2b00 commit b78cb69

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub enum PeeledOnion<CM: CustomOnionMessageContents> {
268268
}
269269

270270
/// Create an onion message with contents `message` to the destination of `path`.
271-
/// Returns (introduction_node_id, onion_msg)
271+
/// Returns (first_node_id, onion_msg)
272272
pub fn create_onion_message<ES: Deref, NS: Deref, T: CustomOnionMessageContents>(
273273
entropy_source: &ES, node_signer: &NS, secp_ctx: &Secp256k1<secp256k1::All>,
274274
path: OnionMessagePath, message: OnionMessageContents<T>, reply_path: Option<BlindedPath>,
@@ -301,8 +301,8 @@ where
301301

302302
let blinding_secret_bytes = entropy_source.get_secure_random_bytes();
303303
let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted");
304-
let (introduction_node_id, blinding_point) = if intermediate_nodes.len() != 0 {
305-
(intermediate_nodes[0], PublicKey::from_secret_key(&secp_ctx, &blinding_secret))
304+
let (first_node_id, blinding_point) = if let Some(first_node_id) = intermediate_nodes.first() {
305+
(*first_node_id, PublicKey::from_secret_key(&secp_ctx, &blinding_secret))
306306
} else {
307307
match destination {
308308
Destination::Node(pk) => (pk, PublicKey::from_secret_key(&secp_ctx, &blinding_secret)),
@@ -318,7 +318,7 @@ where
318318
let onion_routing_packet = construct_onion_message_packet(
319319
packet_payloads, packet_keys, prng_seed).map_err(|()| SendError::TooBigPacket)?;
320320

321-
Ok((introduction_node_id, msgs::OnionMessage {
321+
Ok((first_node_id, msgs::OnionMessage {
322322
blinding_point,
323323
onion_routing_packet
324324
}))
@@ -456,14 +456,14 @@ where
456456
&self, path: OnionMessagePath, message: OnionMessageContents<T>,
457457
reply_path: Option<BlindedPath>
458458
) -> Result<(), SendError> {
459-
let (introduction_node_id, onion_msg) = create_onion_message(
459+
let (first_node_id, onion_msg) = create_onion_message(
460460
&self.entropy_source, &self.node_signer, &self.secp_ctx,
461461
path, message, reply_path
462462
)?;
463463

464464
let mut pending_per_peer_msgs = self.pending_messages.lock().unwrap();
465-
if outbound_buffer_full(&introduction_node_id, &pending_per_peer_msgs) { return Err(SendError::BufferFull) }
466-
match pending_per_peer_msgs.entry(introduction_node_id) {
465+
if outbound_buffer_full(&first_node_id, &pending_per_peer_msgs) { return Err(SendError::BufferFull) }
466+
match pending_per_peer_msgs.entry(first_node_id) {
467467
hash_map::Entry::Vacant(_) => Err(SendError::InvalidFirstHop),
468468
hash_map::Entry::Occupied(mut e) => {
469469
e.get_mut().push_back(onion_msg);

0 commit comments

Comments
 (0)