]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Make clear_initial_routing_sync more consistent with other APIs 2022-09-feature-or
authorMatt Corallo <git@bluematt.me>
Wed, 7 Sep 2022 17:43:14 +0000 (17:43 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 9 Sep 2022 15:36:46 +0000 (15:36 +0000)
lightning/src/ln/features.rs

index e5e9db0352b1a45785fbec38507b31e1b3605c72..91922f1a45f26748f9fdaf8c7ba009a068f6d6b9 100644 (file)
@@ -551,9 +551,9 @@ impl InitFeatures {
        /// Returns the set of known init features that are related to channels. At least some of
        /// these features are likely required for peers to talk to us.
        pub fn known_channel_features() -> InitFeatures {
-               let mut features = Self::known().clear_gossip_queries();
-               features.clear_initial_routing_sync();
-               features
+               Self::known()
+                       .clear_initial_routing_sync()
+                       .clear_gossip_queries()
        }
 }
 
@@ -781,8 +781,9 @@ impl<T: sealed::GossipQueries> Features<T> {
 
 impl<T: sealed::InitialRoutingSync> Features<T> {
        // Note that initial_routing_sync is ignored if gossip_queries is set.
-       pub(crate) fn clear_initial_routing_sync(&mut self) {
-               <T as sealed::InitialRoutingSync>::clear_bits(&mut self.flags)
+       pub(crate) fn clear_initial_routing_sync(mut self) -> Self {
+               <T as sealed::InitialRoutingSync>::clear_bits(&mut self.flags);
+               self
        }
 }
 
@@ -921,7 +922,7 @@ mod tests {
 
                let mut init_features = InitFeatures::known();
                assert!(init_features.initial_routing_sync());
-               init_features.clear_initial_routing_sync();
+               init_features = init_features.clear_initial_routing_sync();
                assert!(!init_features.initial_routing_sync());
        }