Skip to content

Commit 03faad8

Browse files
committed
f Restrict to_context to InitFeatures
1 parent 619f0a9 commit 03faad8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lightning/src/ln/features.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ impl InitFeatures {
282282
}
283283
self
284284
}
285+
286+
/// Converts `InitFeatures` to `Features<C>`. Only known `InitFeatures` relevant to context `C`
287+
/// are included in the result.
288+
pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
289+
self.to_context_internal()
290+
}
285291
}
286292

287293
impl<T: sealed::Context> Features<T> {
@@ -305,7 +311,7 @@ impl<T: sealed::Context> Features<T> {
305311

306312
/// Converts `Features<T>` to `Features<C>`. Only known `T` features relevant to context `C` are
307313
/// included in the result.
308-
pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
314+
fn to_context_internal<C: sealed::Context>(&self) -> Features<C> {
309315
let byte_count = C::KNOWN_FEATURE_MASK.len();
310316
let mut flags = Vec::new();
311317
for (i, byte) in self.flags.iter().enumerate() {
@@ -523,7 +529,7 @@ mod tests {
523529
}
524530

525531
// Check that cleared flags are kept blank when converting back.
526-
let features: InitFeatures = node_features.to_context();
532+
let features: InitFeatures = node_features.to_context_internal();
527533
assert!(!features.initial_routing_sync());
528534
assert!(!features.supports_upfront_shutdown_script());
529535
}

0 commit comments

Comments
 (0)