From 687e587a73d53b58687cc79db28aa21f2908b7cc Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Thu, 13 Apr 2023 13:06:14 -0500 Subject: [PATCH] Define core::ops::BitOr for Features The `lightning-custom-message` crate will need access to Features::or in order combine features of a composite handler. Expose this via a core::ops::BitOr implementation. --- lightning/src/ln/features.rs | 6 ++++-- lightning/src/ln/msgs.rs | 2 +- lightning/src/ln/peer_handler.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 8ccbf4166..f0e2f112a 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -422,8 +422,10 @@ pub struct Features { mark: PhantomData, } -impl Features { - pub(crate) fn or(mut self, o: Self) -> Self { +impl core::ops::BitOr for Features { + type Output = Self; + + fn bitor(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()) { diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index df6a2aba3..02b7b0949 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1392,7 +1392,7 @@ impl Readable for Init { (3, remote_network_address, option) }); Ok(Init { - features: features.or(global_features), + features: features | global_features, remote_network_address, }) } diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 046bbad92..bb6d4b1c5 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1246,8 +1246,8 @@ impl