Skip to content

Commit

Permalink
Decode as required option
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Jul 14, 2022
1 parent c554e64 commit ea80ce1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lightning/src/routing/gossip.rs
Expand Up @@ -643,12 +643,12 @@ impl Writeable for ChannelUpdateInfo {
}
}

struct ChannelUpdateInfoDeserWrap(ChannelUpdateInfo);
struct ChannelUpdateInfoDeserWrap(Option<ChannelUpdateInfo>);

impl MaybeReadable for ChannelUpdateInfoDeserWrap {
fn read<R: io::Read>(reader: &mut R) -> Result<Option<Self>, DecodeError> {
if let Ok(channel_update) = ::util::ser::Readable::read(reader) {
Ok(Some(Self(channel_update)))
if let Ok(channel_update_option) = ::util::ser::Readable::read(reader) {
Ok(Some(Self(channel_update_option)))
} else {
Ok(None)
}
Expand Down Expand Up @@ -808,9 +808,9 @@ impl Readable for ChannelInfo {
Ok(ChannelInfo {
features: init_tlv_based_struct_field!(features, required),
node_one: init_tlv_based_struct_field!(node_one, required),
one_to_two: one_to_two_wrap.map(|w| w.0),
one_to_two: one_to_two_wrap.map(|w| w.0).unwrap_or(None),
node_two: init_tlv_based_struct_field!(node_two, required),
two_to_one: two_to_one_wrap.map(|w| w.0),
two_to_one: two_to_one_wrap.map(|w| w.0).unwrap_or(None),
capacity_sats: init_tlv_based_struct_field!(capacity_sats, required),
announcement_message: init_tlv_based_struct_field!(announcement_message, required),
announcement_received_time: init_tlv_based_struct_field!(announcement_received_time, (default_value, 0)),
Expand Down

0 comments on commit ea80ce1

Please sign in to comment.