Skip to content

Commit

Permalink
Refactor logging in do_accept_inbound_channel function to include con…
Browse files Browse the repository at this point in the history
…text
  • Loading branch information
Jossec101 committed Jan 8, 2024
1 parent ec64b4f commit 429507f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6002,6 +6002,8 @@ where
}

fn do_accept_inbound_channel(&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool, user_channel_id: u128) -> Result<(), APIError> {

let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id));
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);

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

APIError::ChannelUnavailable { err: err_str }
})?;
Expand All @@ -6037,7 +6039,7 @@ where
}
_ => {
let err_str = "No such channel awaiting to be accepted.".to_owned();
log_error!(self.logger, "{}", err_str);
log_error!(logger, "{}", err_str);

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

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

return Err(APIError::APIMisuseError { err: err_str });
}
Expand Down

0 comments on commit 429507f

Please sign in to comment.