From: Valentine Wallace Date: Fri, 9 Sep 2022 15:54:22 +0000 (-0400) Subject: Enable all feature sets to OR with another set of the same type X-Git-Tag: v0.0.111~5^2~7 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=fe8b4c7836cd46558597fb2426a5ffaa6dde5223;p=rust-lightning Enable all feature sets to OR with another set of the same type --- diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 91922f1a4..a680d0184 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -470,6 +470,17 @@ pub struct Features { mark: PhantomData, } +impl Features { + pub(crate) fn or(mut self, o: Self) -> Self { + let total_feature_len = cmp::max(self.flags.len(), o.flags.len()); + self.flags.resize(total_feature_len, 0u8); + for (byte, o_byte) in self.flags.iter_mut().zip(o.flags.iter()) { + *byte |= *o_byte; + } + self + } +} + impl Clone for Features { fn clone(&self) -> Self { Self { @@ -532,16 +543,6 @@ impl InitFeatures { Ok(()) } - /// or's another InitFeatures into this one. - pub(crate) fn or(mut self, o: InitFeatures) -> InitFeatures { - let total_feature_len = cmp::max(self.flags.len(), o.flags.len()); - self.flags.resize(total_feature_len, 0u8); - for (byte, o_byte) in self.flags.iter_mut().zip(o.flags.iter()) { - *byte |= *o_byte; - } - self - } - /// Converts `InitFeatures` to `Features`. Only known `InitFeatures` relevant to context `C` /// are included in the result. pub(crate) fn to_context(&self) -> Features {