From: Valentine Wallace Date: Sat, 25 Feb 2023 00:50:24 +0000 (-0500) Subject: Rename OptionDeserWrapper->RequiredWrapper X-Git-Tag: v0.0.114-beta~3^2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=70c7161dbead8e4b840e81caacd84e024f9eab21;p=rust-lightning Rename OptionDeserWrapper->RequiredWrapper Makes more sense and sets us up for the UpgradableRequired version of it --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index ea24f8cf6..44e1d8c50 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -49,7 +49,7 @@ use crate::chain::onchaintx::OnchainTxHandler; use crate::chain::package::{CounterpartyOfferedHTLCOutput, CounterpartyReceivedHTLCOutput, HolderFundingOutput, HolderHTLCOutput, PackageSolvingData, PackageTemplate, RevokedOutput, RevokedHTLCOutput}; use crate::chain::Filter; use crate::util::logger::Logger; -use crate::util::ser::{Readable, ReadableArgs, MaybeReadable, Writer, Writeable, U48, OptionDeserWrapper}; +use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, MaybeReadable, Writer, Writeable, U48}; use crate::util::byte_utils; use crate::util::events::Event; #[cfg(anchors)] @@ -314,8 +314,8 @@ impl Readable for CounterpartyCommitmentParameters { } } - let mut counterparty_delayed_payment_base_key = OptionDeserWrapper(None); - let mut counterparty_htlc_base_key = OptionDeserWrapper(None); + let mut counterparty_delayed_payment_base_key = RequiredWrapper(None); + let mut counterparty_htlc_base_key = RequiredWrapper(None); let mut on_counterparty_tx_csv: u16 = 0; read_tlv_fields!(r, { (0, counterparty_delayed_payment_base_key, required), diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index f659d6318..99cf4046f 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -6693,7 +6693,7 @@ impl Writeable for ClaimableHTLC { impl Readable for ClaimableHTLC { fn read(reader: &mut R) -> Result { - let mut prev_hop = crate::util::ser::OptionDeserWrapper(None); + let mut prev_hop = crate::util::ser::RequiredWrapper(None); let mut value = 0; let mut payment_data: Option = None; let mut cltv_expiry = 0; @@ -6743,7 +6743,7 @@ impl Readable for HTLCSource { let id: u8 = Readable::read(reader)?; match id { 0 => { - let mut session_priv: crate::util::ser::OptionDeserWrapper = crate::util::ser::OptionDeserWrapper(None); + let mut session_priv: crate::util::ser::RequiredWrapper = crate::util::ser::RequiredWrapper(None); let mut first_hop_htlc_msat: u64 = 0; let mut path = Some(Vec::new()); let mut payment_id = None; diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index 70bf07f95..6e8dd506c 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -23,7 +23,7 @@ use crate::ln::features::ChannelTypeFeatures; use crate::ln::msgs; use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret}; use crate::routing::gossip::NetworkUpdate; -use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, WithoutLength, OptionDeserWrapper}; +use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, RequiredWrapper, WithoutLength}; use crate::routing::router::{RouteHop, RouteParameters}; use bitcoin::{PackedLockTime, Transaction}; @@ -1434,8 +1434,8 @@ impl MaybeReadable for Event { let f = || { let mut channel_id = [0; 32]; let mut user_channel_id: u128 = 0; - let mut counterparty_node_id = OptionDeserWrapper(None); - let mut channel_type = OptionDeserWrapper(None); + let mut counterparty_node_id = RequiredWrapper(None); + let mut channel_type = RequiredWrapper(None); read_tlv_fields!(reader, { (0, channel_id, required), (2, user_channel_id, required), diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 847005e32..36b64b639 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -289,18 +289,18 @@ impl MaybeReadable for T { } /// Wrapper to read a required (non-optional) TLV record. -pub struct OptionDeserWrapper(pub Option); -impl Readable for OptionDeserWrapper { +pub struct RequiredWrapper(pub Option); +impl Readable for RequiredWrapper { #[inline] fn read(reader: &mut R) -> Result { Ok(Self(Some(Readable::read(reader)?))) } } /// When handling `default_values`, we want to map the default-value T directly -/// to a `OptionDeserWrapper` in a way that works for `field: T = t;` as +/// to a `RequiredWrapper` in a way that works for `field: T = t;` as /// well. Thus, we assume `Into for T` does nothing and use that. -impl From for OptionDeserWrapper { - fn from(t: T) -> OptionDeserWrapper { OptionDeserWrapper(Some(t)) } +impl From for RequiredWrapper { + fn from(t: T) -> RequiredWrapper { RequiredWrapper(Some(t)) } } pub(crate) struct U48(pub u64); diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index 3f4b7153a..2aa3846ad 100644 --- a/lightning/src/util/ser_macros.rs +++ b/lightning/src/util/ser_macros.rs @@ -656,13 +656,13 @@ macro_rules! _init_tlv_based_struct_field { #[macro_export] macro_rules! _init_tlv_field_var { ($field: ident, (default_value, $default: expr)) => { - let mut $field = $crate::util::ser::OptionDeserWrapper(None); + let mut $field = $crate::util::ser::RequiredWrapper(None); }; ($field: ident, (static_value, $value: expr)) => { let $field; }; ($field: ident, required) => { - let mut $field = $crate::util::ser::OptionDeserWrapper(None); + let mut $field = $crate::util::ser::RequiredWrapper(None); }; ($field: ident, vec_type) => { let mut $field = Some(Vec::new());