Skip to content

Commit 8ba8e52

Browse files
f - scope instead of mem::drop
1 parent bcccef4 commit 8ba8e52

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
@@ -3796,31 +3796,29 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
37963796

37973797
true
37983798
});
3799+
}
37993800

3800-
mem::drop(channel_state_lock);
3801-
3802-
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3803-
if htlcs.is_empty() {
3804-
// This should be unreachable
3805-
debug_assert!(false);
3801+
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3802+
if htlcs.is_empty() {
3803+
// This should be unreachable
3804+
debug_assert!(false);
3805+
return false;
3806+
}
3807+
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3808+
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3809+
// In this case we're not going to handle any timeouts of the parts here.
3810+
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3811+
return true;
3812+
} else if htlcs.into_iter().any(|htlc| {
3813+
htlc.timer_ticks += 1;
3814+
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3815+
}) {
3816+
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
38063817
return false;
38073818
}
3808-
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3809-
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3810-
// In this case we're not going to handle any timeouts of the parts here.
3811-
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3812-
return true;
3813-
} else if htlcs.into_iter().any(|htlc| {
3814-
htlc.timer_ticks += 1;
3815-
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3816-
}) {
3817-
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
3818-
return false;
3819-
}
3820-
}
3821-
true
3822-
});
3823-
}
3819+
}
3820+
true
3821+
});
38243822

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

0 commit comments

Comments
 (0)