Skip to content

Commit 938769c

Browse files
f - scope instead of mem::drop
1 parent ceb370c commit 938769c

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
@@ -3654,31 +3654,29 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
36543654

36553655
true
36563656
});
3657+
}
36573658

3658-
mem::drop(channel_state_lock);
3659-
3660-
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3661-
if htlcs.is_empty() {
3662-
// This should be unreachable
3663-
debug_assert!(false);
3659+
self.claimable_htlcs.lock().unwrap().retain(|payment_hash, (_, htlcs)| {
3660+
if htlcs.is_empty() {
3661+
// This should be unreachable
3662+
debug_assert!(false);
3663+
return false;
3664+
}
3665+
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3666+
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3667+
// In this case we're not going to handle any timeouts of the parts here.
3668+
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3669+
return true;
3670+
} else if htlcs.into_iter().any(|htlc| {
3671+
htlc.timer_ticks += 1;
3672+
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3673+
}) {
3674+
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
36643675
return false;
36653676
}
3666-
if let OnionPayload::Invoice { .. } = htlcs[0].onion_payload {
3667-
// Check if we've received all the parts we need for an MPP (the value of the parts adds to total_msat).
3668-
// In this case we're not going to handle any timeouts of the parts here.
3669-
if htlcs[0].total_msat == htlcs.iter().fold(0, |total, htlc| total + htlc.value) {
3670-
return true;
3671-
} else if htlcs.into_iter().any(|htlc| {
3672-
htlc.timer_ticks += 1;
3673-
return htlc.timer_ticks >= MPP_TIMEOUT_TICKS
3674-
}) {
3675-
timed_out_mpp_htlcs.extend(htlcs.into_iter().map(|htlc| (htlc.prev_hop.clone(), payment_hash.clone())));
3676-
return false;
3677-
}
3678-
}
3679-
true
3680-
});
3681-
}
3677+
}
3678+
true
3679+
});
36823680

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

0 commit comments

Comments
 (0)