Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look-up functions for ReadOnlyNetworkGraph #1543

Merged
merged 1 commit into from Jul 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 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 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