@@ -274,33 +274,6 @@ impl InitFeatures {
274274 }
275275}
276276
277- impl ChannelFeatures {
278- /// Takes the flags that we know how to interpret in an init-context features that are also
279- /// relevant in a channel-context features and creates a channel-context features from them.
280- pub ( crate ) fn with_known_relevant_init_flags ( _init_ctx : & InitFeatures ) -> Self {
281- // There are currently no channel flags defined that we understand.
282- Self { flags : Vec :: new ( ) , mark : PhantomData , }
283- }
284- }
285-
286- impl NodeFeatures {
287- /// Takes the flags that we know how to interpret in an init-context features that are also
288- /// relevant in a node-context features and creates a node-context features from them.
289- /// Be sure to blank out features that are unknown to us.
290- pub ( crate ) fn with_known_relevant_init_flags ( init_ctx : & InitFeatures ) -> Self {
291- use ln:: features:: sealed:: Context ;
292- let byte_count = sealed:: NodeContext :: KNOWN_FEATURE_MASK . len ( ) ;
293-
294- let mut flags = Vec :: new ( ) ;
295- for ( i, feature_byte) in init_ctx. flags . iter ( ) . enumerate ( ) {
296- if i < byte_count {
297- flags. push ( feature_byte & sealed:: NodeContext :: KNOWN_FEATURE_MASK [ i] ) ;
298- }
299- }
300- Self { flags, mark : PhantomData , }
301- }
302- }
303-
304277impl < T : sealed:: Context > Features < T > {
305278 /// Create a blank Features with no features set
306279 pub fn empty ( ) -> Features < T > {
@@ -318,6 +291,20 @@ impl<T: sealed::Context> Features<T> {
318291 }
319292 }
320293
294+ /// Takes the flags that we know how to interpret in an init-context features that are also
295+ /// relevant in a node-context features and creates a node-context features from them.
296+ /// Be sure to blank out features that are unknown to us.
297+ pub ( crate ) fn with_known_relevant_init_flags ( init_ctx : & InitFeatures ) -> Self {
298+ let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
299+ let mut flags = Vec :: new ( ) ;
300+ for ( i, feature_byte) in init_ctx. flags . iter ( ) . enumerate ( ) {
301+ if i < byte_count {
302+ flags. push ( feature_byte & T :: KNOWN_FEATURE_MASK [ i] ) ;
303+ }
304+ }
305+ Self { flags, mark : PhantomData , }
306+ }
307+
321308 #[ cfg( test) ]
322309 /// Create a Features given a set of flags, in LE.
323310 pub fn from_le_bytes ( flags : Vec < u8 > ) -> Features < T > {
@@ -334,15 +321,13 @@ impl<T: sealed::Context> Features<T> {
334321 }
335322
336323 pub ( crate ) fn requires_unknown_bits ( & self ) -> bool {
337- use ln:: features:: sealed:: Context ;
338- let byte_count = sealed:: InitContext :: UNKNOWN_FEATURE_MASK . len ( ) ;
339-
340324 // Bitwise AND-ing with all even bits set except for known features will select unknown
341325 // required features.
326+ let byte_count = T :: UNKNOWN_FEATURE_MASK . len ( ) ;
342327 self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
343328 let required_features = 0b01_01_01_01 ;
344329 let unknown_features = if i < byte_count {
345- sealed :: InitContext :: UNKNOWN_FEATURE_MASK [ i]
330+ T :: UNKNOWN_FEATURE_MASK [ i]
346331 } else {
347332 0b11_11_11_11
348333 } ;
@@ -351,14 +336,12 @@ impl<T: sealed::Context> Features<T> {
351336 }
352337
353338 pub ( crate ) fn supports_unknown_bits ( & self ) -> bool {
354- use ln:: features:: sealed:: Context ;
355- let byte_count = sealed:: InitContext :: UNKNOWN_FEATURE_MASK . len ( ) ;
356-
357339 // Bitwise AND-ing with all even and odd bits set except for known features will select
358340 // unknown features.
341+ let byte_count = T :: UNKNOWN_FEATURE_MASK . len ( ) ;
359342 self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
360343 let unknown_features = if i < byte_count {
361- sealed :: InitContext :: UNKNOWN_FEATURE_MASK [ i]
344+ T :: UNKNOWN_FEATURE_MASK [ i]
362345 } else {
363346 0b11_11_11_11
364347 } ;
0 commit comments