Skip to content

Commit 43d66c5

Browse files
committed
Clean up MsgHandleErrInternal method annotations and format
Removes totally unnecessary `#[inline]`s on `MsgHandleErrInternal` methods (LLVM will decide for us if it makes sense to inline something, explicit `#[inline(always)]` belongs only on incredibly performance-sensitive code and `#[inline]` belongs only on short public methods that should be inlined into downstream crates) and `rustfmt` `MsgHandleErrInternal::from_chan_no_close`.
1 parent 7a49327 commit 43d66c5

File tree

1 file changed

+24
-39
lines changed

1 file changed

+24
-39
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ struct MsgHandleErrInternal {
875875
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
876876
}
877877
impl MsgHandleErrInternal {
878-
#[inline]
879878
fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self {
880879
Self {
881880
err: LightningError {
@@ -888,11 +887,11 @@ impl MsgHandleErrInternal {
888887
shutdown_finish: None,
889888
}
890889
}
891-
#[inline]
890+
892891
fn from_no_close(err: msgs::LightningError) -> Self {
893892
Self { err, closes_channel: false, shutdown_finish: None }
894893
}
895-
#[inline]
894+
896895
fn from_finish_shutdown(
897896
err: String, channel_id: ChannelId, shutdown_res: ShutdownResult,
898897
channel_update: Option<msgs::ChannelUpdate>,
@@ -912,47 +911,33 @@ impl MsgHandleErrInternal {
912911
shutdown_finish: Some((shutdown_res, channel_update)),
913912
}
914913
}
915-
#[inline]
916-
#[rustfmt::skip]
914+
917915
fn from_chan_no_close(err: ChannelError, channel_id: ChannelId) -> Self {
918-
Self {
919-
err: match err {
920-
ChannelError::Warn(msg) => LightningError {
921-
err: msg.clone(),
922-
action: msgs::ErrorAction::SendWarningMessage {
923-
msg: msgs::WarningMessage {
924-
channel_id,
925-
data: msg
926-
},
927-
log_level: Level::Warn,
928-
},
929-
},
930-
ChannelError::WarnAndDisconnect(msg) => LightningError {
931-
err: msg.clone(),
932-
action: msgs::ErrorAction::DisconnectPeerWithWarning {
933-
msg: msgs::WarningMessage {
934-
channel_id,
935-
data: msg
936-
},
937-
},
916+
let err = match err {
917+
ChannelError::Warn(msg) => LightningError {
918+
err: msg.clone(),
919+
action: msgs::ErrorAction::SendWarningMessage {
920+
msg: msgs::WarningMessage { channel_id, data: msg },
921+
log_level: Level::Warn,
938922
},
939-
ChannelError::Ignore(msg) => LightningError {
940-
err: msg,
941-
action: msgs::ErrorAction::IgnoreError,
923+
},
924+
ChannelError::WarnAndDisconnect(msg) => LightningError {
925+
err: msg.clone(),
926+
action: msgs::ErrorAction::DisconnectPeerWithWarning {
927+
msg: msgs::WarningMessage { channel_id, data: msg },
942928
},
943-
ChannelError::Close((msg, _)) | ChannelError::SendError(msg) => LightningError {
944-
err: msg.clone(),
945-
action: msgs::ErrorAction::SendErrorMessage {
946-
msg: msgs::ErrorMessage {
947-
channel_id,
948-
data: msg
949-
},
950-
},
929+
},
930+
ChannelError::Ignore(msg) => {
931+
LightningError { err: msg, action: msgs::ErrorAction::IgnoreError }
932+
},
933+
ChannelError::Close((msg, _)) | ChannelError::SendError(msg) => LightningError {
934+
err: msg.clone(),
935+
action: msgs::ErrorAction::SendErrorMessage {
936+
msg: msgs::ErrorMessage { channel_id, data: msg },
951937
},
952938
},
953-
closes_channel: false,
954-
shutdown_finish: None,
955-
}
939+
};
940+
Self { err, closes_channel: false, shutdown_finish: None }
956941
}
957942

958943
fn closes_channel(&self) -> bool {

0 commit comments

Comments
 (0)