]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop useless SCID lookup in `claim_funds_from_hop`
authorMatt Corallo <git@bluematt.me>
Wed, 30 Nov 2022 03:02:27 +0000 (03:02 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 30 Nov 2022 03:04:19 +0000 (03:04 +0000)
We have the channel_id available in `prev_hop` so there's no reason
to look it up by SCID.

lightning/src/ln/channelmanager.rs

index 7be667b921628588b2eab6c8a382eefbb9a0789d..a672d01e803e3a2521a3ce87563307ab6f864d0e 100644 (file)
@@ -4195,14 +4195,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
 
        fn claim_funds_from_hop(&self, channel_state_lock: &mut MutexGuard<ChannelHolder<<K::Target as KeysInterface>::Signer>>, prev_hop: HTLCPreviousHopData, payment_preimage: PaymentPreimage) -> ClaimFundsFromHop {
                //TODO: Delay the claimed_funds relaying just like we do outbound relay!
-               let channel_state = &mut **channel_state_lock;
-               let chan_id = match self.short_to_chan_info.read().unwrap().get(&prev_hop.short_channel_id) {
-                       Some((_cp_id, chan_id)) => chan_id.clone(),
-                       None => {
-                               return ClaimFundsFromHop::PrevHopForceClosed
-                       }
-               };
 
+               let chan_id = prev_hop.outpoint.to_channel_id();
+               let channel_state = &mut **channel_state_lock;
                if let hash_map::Entry::Occupied(mut chan) = channel_state.by_id.entry(chan_id) {
                        match chan.get_mut().get_update_fulfill_htlc_and_commit(prev_hop.htlc_id, payment_preimage, &self.logger) {
                                Ok(msgs_monitor_option) => {