Skip to content

Commit b760407

Browse files
authored
Merge pull request #1543 from jkczyz/2022-06-network-graph-bindings
Look-up functions for `ReadOnlyNetworkGraph`
2 parents 2eb93f4 + 2da4953 commit b760407

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning/src/routing/gossip.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,13 +1649,23 @@ impl ReadOnlyNetworkGraph<'_> {
16491649
&*self.channels
16501650
}
16511651

1652+
/// Returns information on a channel with the given id.
1653+
pub fn channel(&self, short_channel_id: u64) -> Option<&ChannelInfo> {
1654+
self.channels.get(&short_channel_id)
1655+
}
1656+
16521657
/// Returns all known nodes' public keys along with announced node info.
16531658
///
16541659
/// (C-not exported) because we have no mapping for `BTreeMap`s
16551660
pub fn nodes(&self) -> &BTreeMap<NodeId, NodeInfo> {
16561661
&*self.nodes
16571662
}
16581663

1664+
/// Returns information on a node with the given id.
1665+
pub fn node(&self, node_id: &NodeId) -> Option<&NodeInfo> {
1666+
self.nodes.get(node_id)
1667+
}
1668+
16591669
/// Get network addresses by node id.
16601670
/// Returns None if the requested node is completely unknown,
16611671
/// or if node announcement for the node was never received.

0 commit comments

Comments
 (0)