-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(lightclient): add CommitClientStatus message to persist client s… #4859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,6 @@ macro_rules! id { | |
id.raw().into() | ||
} | ||
} | ||
|
||
impl From<NonZeroU32> for $T { | ||
fn from(id: NonZeroU32) -> Self { | ||
<$T>::new(id) | ||
|
@@ -96,6 +95,7 @@ id!(ChannelId); | |
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] | ||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] | ||
#[serde(deny_unknown_fields, rename_all = "snake_case")] | ||
#[repr(u8)] | ||
pub enum Status { | ||
Active = 1, | ||
Expired = 2, | ||
|
@@ -111,3 +111,30 @@ impl fmt::Display for Status { | |
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct UnknownEnumVariant { | ||
pub value: u8, | ||
} | ||
Comment on lines
+115
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't redefine this, reuse it from |
||
|
||
impl TryFrom<u8> for Status { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also add a |
||
type Error = UnknownEnumVariant; | ||
|
||
fn try_from(value: u8) -> Result<Self, Self::Error> { | ||
match value { | ||
1 => Ok(Status::Active), | ||
2 => Ok(Status::Expired), | ||
3 => Ok(Status::Frozen), | ||
_ => Err(UnknownEnumVariant { value }), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<U256> for Status { | ||
type Error = UnknownEnumVariant; | ||
|
||
fn try_from(value: U256) -> Result<Self, Self::Error> { | ||
let byte = value.to_le_bytes()[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this drops the majority of the u256. implement this correctly |
||
Status::try_from(byte) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.