]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename OptionDeserWrapper->RequiredWrapper
authorValentine Wallace <vwallace@protonmail.com>
Sat, 25 Feb 2023 00:50:24 +0000 (19:50 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Sat, 25 Feb 2023 01:00:14 +0000 (20:00 -0500)
Makes more sense and sets us up for the UpgradableRequired version of it

lightning/src/chain/channelmonitor.rs
lightning/src/ln/channelmanager.rs
lightning/src/util/events.rs
lightning/src/util/ser.rs
lightning/src/util/ser_macros.rs

index ea24f8cf61d1303a5959fa8e4c6d1aa63ce49cd3..44e1d8c509e07c25c34142c882b2b2f2f593f8e8 100644 (file)
@@ -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),
index f659d63182b874f97e46b53e9755216ed8316a6d..99cf4046fd5f85920b6c5bc05c3d8ae3bec7e6e5 100644 (file)
@@ -6693,7 +6693,7 @@ impl Writeable for ClaimableHTLC {
 
 impl Readable for ClaimableHTLC {
        fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
-               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<msgs::FinalOnionHopData> = 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<SecretKey> = crate::util::ser::OptionDeserWrapper(None);
+                               let mut session_priv: crate::util::ser::RequiredWrapper<SecretKey> = crate::util::ser::RequiredWrapper(None);
                                let mut first_hop_htlc_msat: u64 = 0;
                                let mut path = Some(Vec::new());
                                let mut payment_id = None;
index 70bf07f958ebc9e34084784d3af29a5130c080a8..6e8dd506c75a04eec03d0d708bf6e60b4be095e3 100644 (file)
@@ -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),
index 847005e324e60f5a0e2e42d67e31009571b27e2b..36b64b63900b575c477444b43a51d94c25faf051 100644 (file)
@@ -289,18 +289,18 @@ impl<T: Readable> MaybeReadable for T {
 }
 
 /// Wrapper to read a required (non-optional) TLV record.
-pub struct OptionDeserWrapper<T: Readable>(pub Option<T>);
-impl<T: Readable> Readable for OptionDeserWrapper<T> {
+pub struct RequiredWrapper<T: Readable>(pub Option<T>);
+impl<T: Readable> Readable for RequiredWrapper<T> {
        #[inline]
        fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
                Ok(Self(Some(Readable::read(reader)?)))
        }
 }
 /// When handling `default_values`, we want to map the default-value T directly
-/// to a `OptionDeserWrapper<T>` in a way that works for `field: T = t;` as
+/// to a `RequiredWrapper<T>` in a way that works for `field: T = t;` as
 /// well. Thus, we assume `Into<T> for T` does nothing and use that.
-impl<T: Readable> From<T> for OptionDeserWrapper<T> {
-       fn from(t: T) -> OptionDeserWrapper<T> { OptionDeserWrapper(Some(t)) }
+impl<T: Readable> From<T> for RequiredWrapper<T> {
+       fn from(t: T) -> RequiredWrapper<T> { RequiredWrapper(Some(t)) }
 }
 
 pub(crate) struct U48(pub u64);
index 3f4b7153a7fe7ae2e30bb0e344b19aaf28c3dec4..2aa3846ad99a33ee671209ece86ca1040ac9d82e 100644 (file)
@@ -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());