Merge pull request #1115 from TheBlueMatt/2021-10-expose-addr-vec
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Wed, 13 Oct 2021 16:54:09 +0000 (16:54 +0000)
committerGitHub <noreply@github.com>
Wed, 13 Oct 2021 16:54:09 +0000 (16:54 +0000)
Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result

1  2 
lightning/src/routing/network_graph.rs

index 961939cb7e6dedd4126c8a9daf7e4d839135bc6e,acf51e535d2f682463a15b5119385d05e987377f..f65b8fa657a5fc2e77da24a33578ecf51089e8c4
@@@ -1213,12 -1213,10 +1213,10 @@@ impl ReadOnlyNetworkGraph<'_> 
        /// Get network addresses by node id.
        /// Returns None if the requested node is completely unknown,
        /// or if node announcement for the node was never received.
-       ///
-       /// (C-not exported) as there is no practical way to track lifetimes of returned values.
-       pub fn get_addresses(&self, pubkey: &PublicKey) -> Option<&Vec<NetAddress>> {
+       pub fn get_addresses(&self, pubkey: &PublicKey) -> Option<Vec<NetAddress>> {
                if let Some(node) = self.nodes.get(&NodeId::from_pubkey(&pubkey)) {
                        if let Some(node_info) = node.announcement_info.as_ref() {
-                               return Some(&node_info.addresses)
+                               return Some(node_info.addresses.clone())
                        }
                }
                None
@@@ -1815,7 -1813,6 +1813,7 @@@ mod tests 
                                network_update: Some(NetworkUpdate::ChannelUpdateMessage {
                                        msg: valid_channel_update,
                                }),
 +                              short_channel_id: None,
                                error_code: None,
                                error_data: None,
                        });
                                        short_channel_id,
                                        is_permanent: false,
                                }),
 +                              short_channel_id: None,
                                error_code: None,
                                error_data: None,
                        });
                                        short_channel_id,
                                        is_permanent: true,
                                }),
 +                              short_channel_id: None,
                                error_code: None,
                                error_data: None,
                        });