Skip to content

Commit 7306a8d

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 3ac384d commit 7306a8d

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
@@ -877,7 +877,6 @@ struct MsgHandleErrInternal {
877877
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
878878
}
879879
impl MsgHandleErrInternal {
880-
#[inline]
881880
fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self {
882881
Self {
883882
err: LightningError {
@@ -890,11 +889,11 @@ impl MsgHandleErrInternal {
890889
shutdown_finish: None,
891890
}
892891
}
893-
#[inline]
892+
894893
fn from_no_close(err: msgs::LightningError) -> Self {
895894
Self { err, closes_channel: false, shutdown_finish: None }
896895
}
897-
#[inline]
896+
898897
fn from_finish_shutdown(
899898
err: String, channel_id: ChannelId, shutdown_res: ShutdownResult,
900899
channel_update: Option<msgs::ChannelUpdate>,
@@ -914,47 +913,33 @@ impl MsgHandleErrInternal {
914913
shutdown_finish: Some((shutdown_res, channel_update)),
915914
}
916915
}
917-
#[inline]
918-
#[rustfmt::skip]
916+
919917
fn from_chan_no_close(err: ChannelError, channel_id: ChannelId) -> Self {
920-
Self {
921-
err: match err {
922-
ChannelError::Warn(msg) => LightningError {
923-
err: msg.clone(),
924-
action: msgs::ErrorAction::SendWarningMessage {
925-
msg: msgs::WarningMessage {
926-
channel_id,
927-
data: msg
928-
},
929-
log_level: Level::Warn,
930-
},
931-
},
932-
ChannelError::WarnAndDisconnect(msg) => LightningError {
933-
err: msg.clone(),
934-
action: msgs::ErrorAction::DisconnectPeerWithWarning {
935-
msg: msgs::WarningMessage {
936-
channel_id,
937-
data: msg
938-
},
939-
},
918+
let err = match err {
919+
ChannelError::Warn(msg) => LightningError {
920+
err: msg.clone(),
921+
action: msgs::ErrorAction::SendWarningMessage {
922+
msg: msgs::WarningMessage { channel_id, data: msg },
923+
log_level: Level::Warn,
940924
},
941-
ChannelError::Ignore(msg) => LightningError {
942-
err: msg,
943-
action: msgs::ErrorAction::IgnoreError,
925+
},
926+
ChannelError::WarnAndDisconnect(msg) => LightningError {
927+
err: msg.clone(),
928+
action: msgs::ErrorAction::DisconnectPeerWithWarning {
929+
msg: msgs::WarningMessage { channel_id, data: msg },
944930
},
945-
ChannelError::Close((msg, _)) | ChannelError::SendError(msg) => LightningError {
946-
err: msg.clone(),
947-
action: msgs::ErrorAction::SendErrorMessage {
948-
msg: msgs::ErrorMessage {
949-
channel_id,
950-
data: msg
951-
},
952-
},
931+
},
932+
ChannelError::Ignore(msg) => {
933+
LightningError { err: msg, action: msgs::ErrorAction::IgnoreError }
934+
},
935+
ChannelError::Close((msg, _)) | ChannelError::SendError(msg) => LightningError {
936+
err: msg.clone(),
937+
action: msgs::ErrorAction::SendErrorMessage {
938+
msg: msgs::ErrorMessage { channel_id, data: msg },
953939
},
954940
},
955-
closes_channel: false,
956-
shutdown_finish: None,
957-
}
941+
};
942+
Self { err, closes_channel: false, shutdown_finish: None }
958943
}
959944

960945
fn closes_channel(&self) -> bool {

0 commit comments

Comments
 (0)