Skip to content

Commit 700902d

Browse files
f - scope instead of mem::drop
1 parent 56d6a2c commit 700902d

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,31 +3673,29 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
36733673

36743674
true
36753675
});
3676+
}
36763677

3677-
mem::drop(channel_state_lock);
3678-
3679-
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3680-
if htlcs.is_empty() {
3681-
// This should be unreachable
3682-
debug_assert!(false);
3678+
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3679+
if htlcs.is_empty() {
3680+
// This should be unreachable
3681+
debug_assert!(false);
3682+
return false;
3683+
}
3684+
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3685+
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3686+
// In this case we're not going to handle any timeouts of the parts here.
3687+
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3688+
return true;
3689+
} else if htlcs.into_iter().any(|htlc| {
3690+
htlc.timer_ticks += 1;
3691+
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3692+
}) {
3693+
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
36833694
return false;
36843695
}
3685-
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3686-
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3687-
// In this case we're not going to handle any timeouts of the parts here.
3688-
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3689-
return true;
3690-
} else if htlcs.into_iter().any(|htlc| {
3691-
htlc.timer_ticks += 1;
3692-
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3693-
}) {
3694-
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
3695-
return false;
3696-
}
3697-
}
3698-
true
3699-
});
3700-
}
3696+
}
3697+
true
3698+
});
37013699

37023700
for htlc_source in timed_out_mpp_htlcs.drain(..) {
37033701
let receiver = HTLCDestination::FailedPayment { payment_hash: htlc_source.1 };

0 commit comments

Comments
 (0)