Skip to content

Commit 4a07ac0

Browse files
f - take channel_state lock only when needed
1 parent 2292538 commit 4a07ac0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,14 +2241,14 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
22412241
}
22422242
};
22432243

2244-
let mut channel_state = self.channel_state.lock().unwrap();
22452244
if let &PendingHTLCStatus::Forward(PendingHTLCInfo { ref routing, ref amt_to_forward, ref outgoing_cltv_value, .. }) = &pending_forward_info {
22462245
// If short_channel_id is 0 here, we'll reject the HTLC as there cannot be a channel
22472246
// with a short_channel_id of 0. This is important as various things later assume
22482247
// short_channel_id is non-0 in any ::Forward.
22492248
if let &PendingHTLCRouting::Forward { ref short_channel_id, .. } = routing {
2250-
let id_option = channel_state.short_to_chan_info.get(&short_channel_id).cloned();
22512249
if let Some((err, code, chan_update)) = loop {
2250+
let mut channel_state = self.channel_state.lock().unwrap();
2251+
let id_option = channel_state.short_to_chan_info.get(&short_channel_id).cloned();
22522252
let forwarding_id_opt = match id_option {
22532253
None => { // unknown_next_peer
22542254
// Note that this is likely a timing oracle for detecting whether an scid is a

0 commit comments

Comments
 (0)