Skip to content

Commit b806a40

Browse files
Add a new NodeFeatures constructor to capture the types of flags
When ChannelMessageHandler implementations wish to return a NodeFeatures which contain all the known flags that are relevant to channel handling, but not gossip handling, they currently need to do so by manually constructing a NodeFeatures with all known flags and then clearing the ones they don't want. Instead of spreading this logic across the codebase, this consolidates such construction into one place in features.rs.
1 parent ae8cc52 commit b806a40

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6122,7 +6122,7 @@ impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
61226122
}
61236123

61246124
fn provided_node_features(&self) -> NodeFeatures {
6125-
NodeFeatures::known()
6125+
NodeFeatures::known_channel_features()
61266126
}
61276127

61286128
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {

lightning/src/ln/features.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ impl InitFeatures {
558558
}
559559
}
560560

561+
impl NodeFeatures {
562+
/// Returns the set of known node features that are related to channels. At least some of
563+
/// these features are likely required for peers to talk to us.
564+
pub fn known_channel_features() -> NodeFeatures {
565+
Self::known().clear_gossip_queries()
566+
}
567+
}
568+
561569
impl InvoiceFeatures {
562570
/// Converts `InvoiceFeatures` to `Features<C>`. Only known `InvoiceFeatures` relevant to
563571
/// context `C` are included in the result.

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler {
358358
self.received_msg(wire::Message::Error(msg.clone()));
359359
}
360360
fn provided_node_features(&self) -> NodeFeatures {
361-
NodeFeatures::empty()
361+
NodeFeatures::known_channel_features()
362362
}
363363
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
364364
InitFeatures::known_channel_features()

0 commit comments

Comments
 (0)