mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Add ChannelError::WarnAndDisconnect variant
The existing `ChannelError::Warn` variant only sends the warning and does not disconnect. There are certain cases where we want to just send a warning, and other cases where we want to also disconnect, so we keep both variants around.
This commit is contained in:
parent
5d6e759613
commit
506367e8a9
2 changed files with 19 additions and 4 deletions
|
@ -713,6 +713,7 @@ pub const MIN_THEIR_CHAN_RESERVE_SATOSHIS: u64 = 1000;
|
||||||
pub(super) enum ChannelError {
|
pub(super) enum ChannelError {
|
||||||
Ignore(String),
|
Ignore(String),
|
||||||
Warn(String),
|
Warn(String),
|
||||||
|
WarnAndDisconnect(String),
|
||||||
Close((String, ClosureReason)),
|
Close((String, ClosureReason)),
|
||||||
SendError(String),
|
SendError(String),
|
||||||
}
|
}
|
||||||
|
@ -720,10 +721,11 @@ pub(super) enum ChannelError {
|
||||||
impl fmt::Debug for ChannelError {
|
impl fmt::Debug for ChannelError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
&ChannelError::Ignore(ref e) => write!(f, "Ignore : {}", e),
|
&ChannelError::Ignore(ref e) => write!(f, "Ignore: {}", e),
|
||||||
&ChannelError::Warn(ref e) => write!(f, "Warn : {}", e),
|
&ChannelError::Warn(ref e) => write!(f, "Warn: {}", e),
|
||||||
&ChannelError::Close((ref e, _)) => write!(f, "Close : {}", e),
|
&ChannelError::WarnAndDisconnect(ref e) => write!(f, "Disconnecting with warning: {}", e),
|
||||||
&ChannelError::SendError(ref e) => write!(f, "Not Found : {}", e),
|
&ChannelError::Close((ref e, _)) => write!(f, "Close: {}", e),
|
||||||
|
&ChannelError::SendError(ref e) => write!(f, "Not Found: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -733,6 +735,7 @@ impl fmt::Display for ChannelError {
|
||||||
match self {
|
match self {
|
||||||
&ChannelError::Ignore(ref e) => write!(f, "{}", e),
|
&ChannelError::Ignore(ref e) => write!(f, "{}", e),
|
||||||
&ChannelError::Warn(ref e) => write!(f, "{}", e),
|
&ChannelError::Warn(ref e) => write!(f, "{}", e),
|
||||||
|
&ChannelError::WarnAndDisconnect(ref e) => write!(f, "{}", e),
|
||||||
&ChannelError::Close((ref e, _)) => write!(f, "{}", e),
|
&ChannelError::Close((ref e, _)) => write!(f, "{}", e),
|
||||||
&ChannelError::SendError(ref e) => write!(f, "{}", e),
|
&ChannelError::SendError(ref e) => write!(f, "{}", e),
|
||||||
}
|
}
|
||||||
|
|
|
@ -840,6 +840,15 @@ impl MsgHandleErrInternal {
|
||||||
log_level: Level::Warn,
|
log_level: Level::Warn,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ChannelError::WarnAndDisconnect(msg) => LightningError {
|
||||||
|
err: msg.clone(),
|
||||||
|
action: msgs::ErrorAction::DisconnectPeerWithWarning {
|
||||||
|
msg: msgs::WarningMessage {
|
||||||
|
channel_id,
|
||||||
|
data: msg
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
ChannelError::Ignore(msg) => LightningError {
|
ChannelError::Ignore(msg) => LightningError {
|
||||||
err: msg,
|
err: msg,
|
||||||
action: msgs::ErrorAction::IgnoreError,
|
action: msgs::ErrorAction::IgnoreError,
|
||||||
|
@ -3069,6 +3078,9 @@ macro_rules! convert_channel_err {
|
||||||
ChannelError::Warn(msg) => {
|
ChannelError::Warn(msg) => {
|
||||||
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), *$channel_id))
|
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), *$channel_id))
|
||||||
},
|
},
|
||||||
|
ChannelError::WarnAndDisconnect(msg) => {
|
||||||
|
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::WarnAndDisconnect(msg), *$channel_id))
|
||||||
|
},
|
||||||
ChannelError::Ignore(msg) => {
|
ChannelError::Ignore(msg) => {
|
||||||
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), *$channel_id))
|
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), *$channel_id))
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue