Skip to content

Commit 718ade1

Browse files
committed
f much better indentation from val
1 parent 5b1ee5e commit 718ade1

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8309,49 +8309,51 @@ where
83098309
// Whether the downstream channel was closed or not, try to re-apply any payment
83108310
// preimages from it which may be needed in upstream channels for forwarded
83118311
// payments.
8312-
for (htlc_source, (htlc, preimage_opt)) in monitor.get_all_current_outbound_htlcs() {
8313-
match htlc_source {
8314-
HTLCSource::PreviousHopData(prev_hop_data) => {
8312+
let outbound_claimed_htlcs_iter = monitor.get_all_current_outbound_htlcs()
8313+
.into_iter()
8314+
.filter_map(|(htlc_source, (htlc, preimage_opt))| {
8315+
if let HTLCSource::PreviousHopData(prev_hop_data) = htlc_source {
83158316
if let Some(payment_preimage) = preimage_opt {
8316-
let mut is_chan_open = false;
8317-
if let Some((node_id, chan_id)) = short_to_chan_info.get(&prev_hop_data.short_channel_id) {
8318-
if let Some(mut peer) = per_peer_state.get_mut(node_id).map(|node| node.lock().unwrap()) {
8319-
if let Some(chan) = peer.channel_by_id.get_mut(chan_id) {
8320-
is_chan_open = true;
8321-
match chan.get_update_fulfill_htlc_and_commit(prev_hop_data.htlc_id, payment_preimage, &args.logger) {
8322-
UpdateFulfillCommitFetch::DuplicateClaim {} => {},
8323-
UpdateFulfillCommitFetch::NewClaim { monitor_update, .. } => {
8324-
// The ChannelMonitor that gave us this
8325-
// preimage is for a now-closed channel -
8326-
// no further updates to that channel can
8327-
// happen which would result in the
8328-
// preimage being removed, thus we're
8329-
// guaranteed to regenerate this claim on
8330-
// restart as long as the source monitor
8331-
// sticks around.
8332-
pending_background_events.push(
8333-
BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
8334-
counterparty_node_id: *node_id,
8335-
funding_txo: prev_hop_data.outpoint,
8336-
update: monitor_update.clone()
8337-
});
8338-
},
8339-
}
8340-
}
8341-
}
8342-
}
8343-
if !is_chan_open {
8344-
let monitor_update = ChannelMonitorUpdate {
8345-
update_id: CLOSED_CHANNEL_UPDATE_ID,
8346-
updates: vec![ChannelMonitorUpdateStep::PaymentPreimage { payment_preimage }],
8347-
};
8348-
pending_background_events.push(BackgroundEvent::
8349-
ClosingMonitorUpdateRegeneratedOnStartup(
8350-
(prev_hop_data.outpoint, monitor_update)));
8317+
Some((prev_hop_data, htlc, payment_preimage))
8318+
} else { None }
8319+
} else { None }
8320+
});
8321+
for (prev_hop_data, htlc, payment_preimage) in outbound_claimed_htlcs_iter {
8322+
let mut is_chan_open = false;
8323+
if let Some((node_id, chan_id)) = short_to_chan_info.get(&prev_hop_data.short_channel_id) {
8324+
if let Some(mut peer) = per_peer_state.get_mut(node_id).map(|node| node.lock().unwrap()) {
8325+
if let Some(chan) = peer.channel_by_id.get_mut(chan_id) {
8326+
is_chan_open = true;
8327+
match chan.get_update_fulfill_htlc_and_commit(prev_hop_data.htlc_id, payment_preimage, &args.logger) {
8328+
UpdateFulfillCommitFetch::DuplicateClaim {} => {},
8329+
UpdateFulfillCommitFetch::NewClaim { monitor_update, .. } => {
8330+
// The ChannelMonitor that gave us this
8331+
// preimage is for a now-closed channel -
8332+
// no further updates to that channel can
8333+
// happen which would result in the
8334+
// preimage being removed, thus we're
8335+
// guaranteed to regenerate this claim on
8336+
// restart as long as the source monitor
8337+
// sticks around.
8338+
pending_background_events.push(
8339+
BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
8340+
counterparty_node_id: *node_id,
8341+
funding_txo: prev_hop_data.outpoint,
8342+
update: monitor_update.clone()
8343+
});
8344+
},
83518345
}
83528346
}
8353-
},
8354-
_ => {},
8347+
}
8348+
}
8349+
if !is_chan_open {
8350+
let monitor_update = ChannelMonitorUpdate {
8351+
update_id: CLOSED_CHANNEL_UPDATE_ID,
8352+
updates: vec![ChannelMonitorUpdateStep::PaymentPreimage { payment_preimage }],
8353+
};
8354+
pending_background_events.push(
8355+
BackgroundEvent::ClosingMonitorUpdateRegeneratedOnStartup(
8356+
(prev_hop_data.outpoint, monitor_update)));
83558357
}
83568358
}
83578359
}

0 commit comments

Comments
 (0)