Skip to content

Commit dcaf0b3

Browse files
committed
Remove unnecessary return value from force_close_channel_with_peer
`ChannelManager::force_close_channel_with_peer` takes the peer's node_id as a parameter and then returns it, presumably leftover from before we stored channels indexed by peers. Here we simply drop the return value.
1 parent 61a37b1 commit dcaf0b3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,11 +4368,11 @@ where
43684368
/// user closes, which will be re-exposed as the `ChannelClosed` reason.
43694369
#[rustfmt::skip]
43704370
fn force_close_channel_with_peer(&self, channel_id: &ChannelId, peer_node_id: &PublicKey, peer_msg: Option<&String>, broadcast: bool)
4371-
-> Result<PublicKey, APIError> {
4371+
-> Result<(), APIError> {
43724372
let per_peer_state = self.per_peer_state.read().unwrap();
43734373
let peer_state_mutex = per_peer_state.get(peer_node_id)
43744374
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", peer_node_id) })?;
4375-
let (update_opt, counterparty_node_id) = {
4375+
let update_opt = {
43764376
let mut peer_state = peer_state_mutex.lock().unwrap();
43774377
let closure_reason = if let Some(peer_msg) = peer_msg {
43784378
ClosureReason::CounterpartyForceClosed { peer_msg: UntrustedString(peer_msg.to_string()) }
@@ -4394,17 +4394,17 @@ where
43944394
(chan_entry.get_mut().force_shutdown(false, closure_reason), None)
43954395
},
43964396
};
4397-
let chan = remove_channel_entry!(self, peer_state, chan_entry, shutdown_res);
4397+
remove_channel_entry!(self, peer_state, chan_entry, shutdown_res);
43984398
mem::drop(peer_state);
43994399
mem::drop(per_peer_state);
44004400
self.finish_close_channel(shutdown_res);
4401-
(update_opt, chan.context().get_counterparty_node_id())
4401+
update_opt
44024402
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
44034403
log_error!(logger, "Force-closing channel {}", &channel_id);
44044404
// N.B. that we don't send any channel close event here: we
44054405
// don't have a user_channel_id, and we never sent any opening
44064406
// events anyway.
4407-
(None, *peer_node_id)
4407+
None
44084408
} else {
44094409
return Err(APIError::ChannelUnavailable{ err: format!("Channel with id {} not found for the passed counterparty node_id {}", channel_id, peer_node_id) });
44104410
}
@@ -4416,8 +4416,7 @@ where
44164416
msg: update
44174417
});
44184418
}
4419-
4420-
Ok(counterparty_node_id)
4419+
Ok(())
44214420
}
44224421

44234422
#[rustfmt::skip]
@@ -4427,13 +4426,13 @@ where
44274426
log_debug!(self.logger,
44284427
"Force-closing channel, The error message sent to the peer : {}", error_message);
44294428
match self.force_close_channel_with_peer(channel_id, &counterparty_node_id, None, broadcast) {
4430-
Ok(counterparty_node_id) => {
4429+
Ok(()) => {
44314430
let per_peer_state = self.per_peer_state.read().unwrap();
4432-
if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) {
4431+
if let Some(peer_state_mutex) = per_peer_state.get(counterparty_node_id) {
44334432
let mut peer_state = peer_state_mutex.lock().unwrap();
44344433
peer_state.pending_msg_events.push(
44354434
MessageSendEvent::HandleError {
4436-
node_id: counterparty_node_id,
4435+
node_id: *counterparty_node_id,
44374436
action: msgs::ErrorAction::SendErrorMessage {
44384437
msg: msgs::ErrorMessage { channel_id: *channel_id, data: error_message }
44394438
},

0 commit comments

Comments
 (0)