Skip to content

Commit 0f7fc5c

Browse files
committed
f rm side-effects from and_then
1 parent efa7aed commit 0f7fc5c

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8063,7 +8063,7 @@ where
80638063
peer_state.pending_msg_events.push(msg_send_event);
80648064
};
80658065
if let Some(mut signing_session) = signing_session_opt {
8066-
match chan_phase_entry.get_mut() {
8066+
let (commitment_signed, funding_ready_for_sig_event_opt) = match chan_phase_entry.get_mut() {
80678067
ChannelPhase::UnfundedOutboundV2(chan) => {
80688068
chan.funding_tx_constructed(&mut signing_session, &self.logger)
80698069
},
@@ -8073,23 +8073,18 @@ where
80738073
_ => Err(ChannelError::Warn(
80748074
"Got a tx_complete message with no interactive transaction construction expected or in-progress"
80758075
.into())),
8076-
}.and_then(|(commitment_signed, funding_ready_for_sig_event_opt)| {
8077-
let (channel_id, channel_phase) = chan_phase_entry.remove_entry();
8078-
match channel_phase {
8079-
ChannelPhase::UnfundedOutboundV2(chan) => {
8080-
chan.into_channel(signing_session)
8081-
},
8082-
ChannelPhase::UnfundedInboundV2(chan) => {
8083-
chan.into_channel(signing_session)
8084-
},
8076+
}.map_err(|err| MsgHandleErrInternal::send_err_msg_no_close(format!("{}", err), msg.channel_id))?;
8077+
let (channel_id, channel_phase) = chan_phase_entry.remove_entry();
8078+
let channel = match channel_phase {
8079+
ChannelPhase::UnfundedOutboundV2(chan) => chan.into_channel(signing_session),
8080+
ChannelPhase::UnfundedInboundV2(chan) => chan.into_channel(signing_session),
80858081
_ => {
80868082
debug_assert!(false); // It cannot be another variant as we are in the `Ok` branch of the above match.
80878083
Err(ChannelError::Warn(
80888084
"Got a tx_complete message with no interactive transaction construction expected or in-progress"
80898085
.into()))
8090-
}
8091-
}.map(|channel| (channel_id, channel, funding_ready_for_sig_event_opt, commitment_signed))
8092-
}).map(|(channel_id, channel, funding_ready_for_sig_event_opt, commitment_signed)| {
8086+
},
8087+
}.map_err(|err| MsgHandleErrInternal::send_err_msg_no_close(format!("{}", err), msg.channel_id))?;
80938088
peer_state.channel_by_id.insert(channel_id, ChannelPhase::Funded(channel));
80948089
if let Some(funding_ready_for_sig_event) = funding_ready_for_sig_event_opt {
80958090
let mut pending_events = self.pending_events.lock().unwrap();
@@ -8106,11 +8101,8 @@ where
81068101
update_fee: None,
81078102
},
81088103
});
8109-
}).map_err(|err| MsgHandleErrInternal::send_err_msg_no_close(format!("{}", err), msg.channel_id))
8110-
} else {
8111-
// We're not in a signing session yet so we don't need to do anything else.
8112-
Ok(())
8113-
}
8104+
}
8105+
Ok(())
81148106
},
81158107
hash_map::Entry::Vacant(_) => {
81168108
Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))

0 commit comments

Comments
 (0)