Skip to content

Commit 4055dc0

Browse files
Enable all feature sets to OR with another set of the same type
1 parent 1b67b0b commit 4055dc0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lightning/src/ln/features.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,17 @@ pub struct Features<T: sealed::Context> {
470470
mark: PhantomData<T>,
471471
}
472472

473+
impl <T: sealed::Context> Features<T> {
474+
pub(crate) fn or(mut self, o: Self) -> Self {
475+
let total_feature_len = cmp::max(self.flags.len(), o.flags.len());
476+
self.flags.resize(total_feature_len, 0u8);
477+
for (byte, o_byte) in self.flags.iter_mut().zip(o.flags.iter()) {
478+
*byte |= *o_byte;
479+
}
480+
self
481+
}
482+
}
483+
473484
impl<T: sealed::Context> Clone for Features<T> {
474485
fn clone(&self) -> Self {
475486
Self {
@@ -532,16 +543,6 @@ impl InitFeatures {
532543
Ok(())
533544
}
534545

535-
/// or's another InitFeatures into this one.
536-
pub(crate) fn or(mut self, o: InitFeatures) -> InitFeatures {
537-
let total_feature_len = cmp::max(self.flags.len(), o.flags.len());
538-
self.flags.resize(total_feature_len, 0u8);
539-
for (byte, o_byte) in self.flags.iter_mut().zip(o.flags.iter()) {
540-
*byte |= *o_byte;
541-
}
542-
self
543-
}
544-
545546
/// Converts `InitFeatures` to `Features<C>`. Only known `InitFeatures` relevant to context `C`
546547
/// are included in the result.
547548
pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {

0 commit comments

Comments
 (0)