@@ -274,33 +274,6 @@ impl InitFeatures {
274
274
}
275
275
}
276
276
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
-
304
277
impl < T : sealed:: Context > Features < T > {
305
278
/// Create a blank Features with no features set
306
279
pub fn empty ( ) -> Features < T > {
@@ -318,6 +291,20 @@ impl<T: sealed::Context> Features<T> {
318
291
}
319
292
}
320
293
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
+
321
308
#[ cfg( test) ]
322
309
/// Create a Features given a set of flags, in LE.
323
310
pub fn from_le_bytes ( flags : Vec < u8 > ) -> Features < T > {
@@ -334,15 +321,13 @@ impl<T: sealed::Context> Features<T> {
334
321
}
335
322
336
323
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
-
340
324
// Bitwise AND-ing with all even bits set except for known features will select unknown
341
325
// required features.
326
+ let byte_count = T :: UNKNOWN_FEATURE_MASK . len ( ) ;
342
327
self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
343
328
let required_features = 0b01_01_01_01 ;
344
329
let unknown_features = if i < byte_count {
345
- sealed :: InitContext :: UNKNOWN_FEATURE_MASK [ i]
330
+ T :: UNKNOWN_FEATURE_MASK [ i]
346
331
} else {
347
332
0b11_11_11_11
348
333
} ;
@@ -351,14 +336,12 @@ impl<T: sealed::Context> Features<T> {
351
336
}
352
337
353
338
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
-
357
339
// Bitwise AND-ing with all even and odd bits set except for known features will select
358
340
// unknown features.
341
+ let byte_count = T :: UNKNOWN_FEATURE_MASK . len ( ) ;
359
342
self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
360
343
let unknown_features = if i < byte_count {
361
- sealed :: InitContext :: UNKNOWN_FEATURE_MASK [ i]
344
+ T :: UNKNOWN_FEATURE_MASK [ i]
362
345
} else {
363
346
0b11_11_11_11
364
347
} ;
0 commit comments