From d2b7f6cc08fc517d620c7de6592b3ddc188f8f96 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 11 Oct 2021 23:46:51 +0000 Subject: [PATCH] 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. --- lightning/src/routing/network_graph.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 -- 2.39.5