From: Matt Corallo Date: Mon, 11 Oct 2021 23:46:51 +0000 (+0000) Subject: Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result X-Git-Tag: v0.0.102~6^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=refs%2Fheads%2F2021-10-expose-addr-vec;p=rust-lightning Expose ReadOnlyNetworkGraph::get_addresses to C by cloning result We cannot expose ReadOnlyNetworkGraph::get_addresses as is in C as it returns a list of references to an enum, which the bindings dont support. Instead, we simply clone the result so that it doesn't contain references. --- diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 2a8c45c3b..acf51e535 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -1213,12 +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> { + pub fn get_addresses(&self, pubkey: &PublicKey) -> Option> { 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