From fe8b4c7836cd46558597fb2426a5ffaa6dde5223 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Fri, 9 Sep 2022 11:54:22 -0400 Subject: [PATCH] Enable all feature sets to OR with another set of the same type --- lightning/src/ln/features.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 91922f1a..a680d018 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 { -- 2.30.2