Skip to content

Commit d024251

Browse files
authored
Merge pull request #1651 from TheBlueMatt/2022-08-export-chan-list
[C Bindings] Expose channel and nodes list in `ReadOnlyNetworkGraph`
2 parents 11b7ab7 + fc771d3 commit d024251

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lightning/src/routing/gossip.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,12 @@ impl ReadOnlyNetworkGraph<'_> {
17961796
self.channels.get(&short_channel_id)
17971797
}
17981798

1799+
#[cfg(c_bindings)] // Non-bindings users should use `channels`
1800+
/// Returns the list of channels in the graph
1801+
pub fn list_channels(&self) -> Vec<u64> {
1802+
self.channels.keys().map(|c| *c).collect()
1803+
}
1804+
17991805
/// Returns all known nodes' public keys along with announced node info.
18001806
///
18011807
/// (C-not exported) because we have no mapping for `BTreeMap`s
@@ -1808,6 +1814,12 @@ impl ReadOnlyNetworkGraph<'_> {
18081814
self.nodes.get(node_id)
18091815
}
18101816

1817+
#[cfg(c_bindings)] // Non-bindings users should use `nodes`
1818+
/// Returns the list of nodes in the graph
1819+
pub fn list_nodes(&self) -> Vec<NodeId> {
1820+
self.nodes.keys().map(|n| *n).collect()
1821+
}
1822+
18111823
/// Get network addresses by node id.
18121824
/// Returns None if the requested node is completely unknown,
18131825
/// or if node announcement for the node was never received.

0 commit comments

Comments
 (0)