@@ -4848,36 +4848,25 @@ where
48484848 .map_err(|e| {
48494849 let first_hop_key = Some(path.hops.first().unwrap().pubkey);
48504850 let logger = WithContext::from(&self.logger, first_hop_key, None, Some(*payment_hash));
4851- log_error!(
4852- logger,
4853- "Failed to build an onion for path for payment hash {}",
4854- payment_hash
4855- );
4851+ log_error!(logger, "Failed to build an onion for path for payment hash {payment_hash}");
48564852 e
48574853 })?;
48584854
48594855 let err: Result<(), _> = loop {
4860- let first_chan_id = &path.hops.first().unwrap().short_channel_id;
4861- let (counterparty_node_id, id) = match self
4862- .short_to_chan_info
4863- .read()
4864- .unwrap()
4865- .get(first_chan_id)
4866- {
4856+ let first_chan_scid = &path.hops.first().unwrap().short_channel_id;
4857+ let first_chan = self.short_to_chan_info.read().unwrap().get(first_chan_scid).cloned();
4858+
4859+ let (counterparty_node_id, id) = match first_chan {
48674860 None => {
48684861 let first_hop_key = Some(path.hops.first().unwrap().pubkey);
48694862 let logger =
48704863 WithContext::from(&self.logger, first_hop_key, None, Some(*payment_hash));
4871- log_error!(
4872- logger,
4873- "Failed to find first-hop for payment hash {}",
4874- payment_hash
4875- );
4864+ log_error!(logger, "Failed to find first-hop for payment hash {payment_hash}");
48764865 return Err(APIError::ChannelUnavailable {
48774866 err: "No channel available with first hop!".to_owned(),
48784867 });
48794868 },
4880- Some((cp_id, chan_id)) => (cp_id.clone() , chan_id.clone() ),
4869+ Some((cp_id, chan_id)) => (cp_id, chan_id),
48814870 };
48824871
48834872 let logger = WithContext::from(
@@ -4888,9 +4877,7 @@ where
48884877 );
48894878 log_trace!(
48904879 logger,
4891- "Attempting to send payment with payment hash {} along path with next hop {}",
4892- payment_hash,
4893- first_chan_id,
4880+ "Attempting to send payment with payment hash {payment_hash} along path with next hop {first_chan_scid}"
48944881 );
48954882
48964883 let per_peer_state = self.per_peer_state.read().unwrap();
@@ -4924,7 +4911,7 @@ where
49244911 };
49254912 let send_res = chan.send_htlc_and_commit(
49264913 htlc_msat,
4927- payment_hash.clone() ,
4914+ * payment_hash,
49284915 htlc_cltv,
49294916 htlc_source,
49304917 onion_packet,
0 commit comments