@@ -269,33 +269,6 @@ impl InitFeatures {
269
269
}
270
270
}
271
271
272
- impl ChannelFeatures {
273
- /// Takes the flags that we know how to interpret in an init-context features that are also
274
- /// relevant in a channel-context features and creates a channel-context features from them.
275
- pub ( crate ) fn with_known_relevant_init_flags ( _init_ctx : & InitFeatures ) -> Self {
276
- // There are currently no channel flags defined that we understand.
277
- Self { flags : Vec :: new ( ) , mark : PhantomData , }
278
- }
279
- }
280
-
281
- impl NodeFeatures {
282
- /// Takes the flags that we know how to interpret in an init-context features that are also
283
- /// relevant in a node-context features and creates a node-context features from them.
284
- /// Be sure to blank out features that are unknown to us.
285
- pub ( crate ) fn with_known_relevant_init_flags ( init_ctx : & InitFeatures ) -> Self {
286
- use ln:: features:: sealed:: Context ;
287
- let byte_count = sealed:: NodeContext :: KNOWN_FEATURE_MASK . len ( ) ;
288
-
289
- let mut flags = Vec :: new ( ) ;
290
- for ( i, feature_byte) in init_ctx. flags . iter ( ) . enumerate ( ) {
291
- if i < byte_count {
292
- flags. push ( feature_byte & sealed:: NodeContext :: KNOWN_FEATURE_MASK [ i] ) ;
293
- }
294
- }
295
- Self { flags, mark : PhantomData , }
296
- }
297
- }
298
-
299
272
impl < T : sealed:: Context > Features < T > {
300
273
/// Create a blank Features with no features set
301
274
pub fn empty ( ) -> Features < T > {
@@ -315,6 +288,20 @@ impl<T: sealed::Context> Features<T> {
315
288
}
316
289
}
317
290
291
+ /// Takes the flags that we know how to interpret in an init-context features that are also
292
+ /// relevant in a node-context features and creates a node-context features from them.
293
+ /// Be sure to blank out features that are unknown to us.
294
+ pub ( crate ) fn with_known_relevant_init_flags ( init_ctx : & InitFeatures ) -> Self {
295
+ let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
296
+ let mut flags = Vec :: new ( ) ;
297
+ for ( i, feature_byte) in init_ctx. flags . iter ( ) . enumerate ( ) {
298
+ if i < byte_count {
299
+ flags. push ( feature_byte & T :: KNOWN_FEATURE_MASK [ i] ) ;
300
+ }
301
+ }
302
+ Self { flags, mark : PhantomData , }
303
+ }
304
+
318
305
#[ cfg( test) ]
319
306
/// Create a Features given a set of flags, in LE.
320
307
pub fn from_le_bytes ( flags : Vec < u8 > ) -> Features < T > {
@@ -331,15 +318,13 @@ impl<T: sealed::Context> Features<T> {
331
318
}
332
319
333
320
pub ( crate ) fn requires_unknown_bits ( & self ) -> bool {
334
- use ln:: features:: sealed:: Context ;
335
- let byte_count = sealed:: InitContext :: KNOWN_FEATURE_MASK . len ( ) ;
336
-
337
321
// Bitwise AND-ing with all even bits set except for known features will select unknown
338
322
// required features.
323
+ let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
339
324
self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
340
325
let required_features = 0b01_01_01_01 ;
341
326
let unknown_features = if i < byte_count {
342
- !sealed :: InitContext :: KNOWN_FEATURE_MASK [ i]
327
+ !T :: KNOWN_FEATURE_MASK [ i]
343
328
} else {
344
329
0b11_11_11_11
345
330
} ;
@@ -348,14 +333,12 @@ impl<T: sealed::Context> Features<T> {
348
333
}
349
334
350
335
pub ( crate ) fn supports_unknown_bits ( & self ) -> bool {
351
- use ln:: features:: sealed:: Context ;
352
- let byte_count = sealed:: InitContext :: KNOWN_FEATURE_MASK . len ( ) ;
353
-
354
336
// Bitwise AND-ing with all even and odd bits set except for known features will select
355
337
// unknown features.
338
+ let byte_count = T :: KNOWN_FEATURE_MASK . len ( ) ;
356
339
self . flags . iter ( ) . enumerate ( ) . any ( |( i, & byte) | {
357
340
let unknown_features = if i < byte_count {
358
- !sealed :: InitContext :: KNOWN_FEATURE_MASK [ i]
341
+ !T :: KNOWN_FEATURE_MASK [ i]
359
342
} else {
360
343
0b11_11_11_11
361
344
} ;
0 commit comments