Skip to content

Commit

Permalink
Look-up functions for ReadOnlyNetworkGraph
Browse files Browse the repository at this point in the history
ReadOnlyNetworkGraph uses BTreeMap to store its nodes and channels, but
these data structures are not supported by C bindings. Expose look-up
functions on these maps in lieu of such support.
  • Loading branch information
jkczyz committed Jul 14, 2022
1 parent 22dc964 commit 3024b07
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lightning/src/routing/gossip.rs
Expand Up @@ -1602,13 +1602,23 @@ impl ReadOnlyNetworkGraph<'_> {
&*self.channels
}

/// Returns information on a channel with the given id.
pub fn get_channel(&self, short_channel_id: u64) -> Option<&ChannelInfo> {
self.channels.get(&short_channel_id)
}

/// Returns all known nodes' public keys along with announced node info.
///
/// (C-not exported) because we have no mapping for `BTreeMap`s
pub fn nodes(&self) -> &BTreeMap<NodeId, NodeInfo> {
&*self.nodes
}

/// Returns information on a node with the given id.
pub fn get_node(&self, node_id: &NodeId) -> Option<&NodeInfo> {
self.nodes.get(node_id)
}

/// 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.
Expand Down

0 comments on commit 3024b07

Please sign in to comment.