Skip to content

Commit 2d92b55

Browse files
committed
Refactor logging in do_accept_inbound_channel function to include context
1 parent 66c9b68 commit 2d92b55

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,6 +6002,8 @@ where
60026002
}
60036003

60046004
fn do_accept_inbound_channel(&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool, user_channel_id: u128) -> Result<(), APIError> {
6005+
6006+
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id));
60056007
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
60066008

60076009
let peers_without_funded_channels =
@@ -6010,7 +6012,7 @@ where
60106012
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
60116013
.ok_or_else(|| {
60126014
let err_str = format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id);
6013-
log_error!(self.logger, "{}", err_str);
6015+
log_error!(logger, "{}", err_str);
60146016

60156017
APIError::ChannelUnavailable { err: err_str }
60166018
})?;
@@ -6030,14 +6032,14 @@ where
60306032
&unaccepted_channel.open_channel_msg, user_channel_id, &self.default_configuration, best_block_height,
60316033
&self.logger, accept_0conf).map_err(|e| {
60326034
let err_str = e.to_string();
6033-
log_error!(self.logger, "{}", err_str);
6035+
log_error!(logger, "{}", err_str);
60346036

60356037
APIError::ChannelUnavailable { err: err_str }
60366038
})
60376039
}
60386040
_ => {
60396041
let err_str = "No such channel awaiting to be accepted.".to_owned();
6040-
log_error!(self.logger, "{}", err_str);
6042+
log_error!(logger, "{}", err_str);
60416043

60426044
Err(APIError::APIMisuseError { err: err_str })
60436045
}
@@ -6055,7 +6057,7 @@ where
60556057
};
60566058
peer_state.pending_msg_events.push(send_msg_err_event);
60576059
let err_str = "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations.".to_owned();
6058-
log_error!(self.logger, "{}", err_str);
6060+
log_error!(logger, "{}", err_str);
60596061

60606062
return Err(APIError::APIMisuseError { err: err_str });
60616063
} else {
@@ -6071,7 +6073,7 @@ where
60716073
};
60726074
peer_state.pending_msg_events.push(send_msg_err_event);
60736075
let err_str = "Too many peers with unfunded channels, refusing to accept new ones".to_owned();
6074-
log_error!(self.logger, "{}", err_str);
6076+
log_error!(logger, "{}", err_str);
60756077

60766078
return Err(APIError::APIMisuseError { err: err_str });
60776079
}

0 commit comments

Comments
 (0)