Skip to content

Commit 2da4953

Browse files
committed
Look-up functions for ReadOnlyNetworkGraph
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.
1 parent 22dc964 commit 2da4953

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
@@ -1602,13 +1602,23 @@ impl ReadOnlyNetworkGraph<'_> {
16021602
&*self.channels
16031603
}
16041604

1605+
/// Returns information on a channel with the given id.
1606+
pub fn channel(&self, short_channel_id: u64) -> Option<&ChannelInfo> {
1607+
self.channels.get(&short_channel_id)
1608+
}
1609+
16051610
/// Returns all known nodes' public keys along with announced node info.
16061611
///
16071612
/// (C-not exported) because we have no mapping for `BTreeMap`s
16081613
pub fn nodes(&self) -> &BTreeMap<NodeId, NodeInfo> {
16091614
&*self.nodes
16101615
}
16111616

1617+
/// Returns information on a node with the given id.
1618+
pub fn node(&self, node_id: &NodeId) -> Option<&NodeInfo> {
1619+
self.nodes.get(node_id)
1620+
}
1621+
16121622
/// Get network addresses by node id.
16131623
/// Returns None if the requested node is completely unknown,
16141624
/// or if node announcement for the node was never received.

0 commit comments

Comments
 (0)