Skip to content

Commit 2d50c17

Browse files
committed
Expose nodes and channels in C bindings
ReadOnlyNetworkGraph uses BTreeMap to store its nodes and channels, but these data structures are not supported by C bindings. Expose them as Vecs instead.
1 parent 22dc964 commit 2d50c17

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

1605+
#[cfg(c_bindings)]
1606+
/// Returns all known valid channels' short ids along with announced channel info.
1607+
pub fn channels_vec(&self) -> Vec<(u64, ChannelInfo)> {
1608+
self.channels.iter().map(|(id, info)| (*id, info.clone())).collect()
1609+
}
1610+
16051611
/// Returns all known nodes' public keys along with announced node info.
16061612
///
16071613
/// (C-not exported) because we have no mapping for `BTreeMap`s
16081614
pub fn nodes(&self) -> &BTreeMap<NodeId, NodeInfo> {
16091615
&*self.nodes
16101616
}
16111617

1618+
#[cfg(c_bindings)]
1619+
/// Returns all known nodes' public keys along with announced node info.
1620+
pub fn nodes_vec(&'_ self) -> Vec<(NodeId, NodeInfo)> {
1621+
self.nodes.iter().map(|(id, info)| (*id, info.clone())).collect()
1622+
}
1623+
16121624
/// Get network addresses by node id.
16131625
/// Returns None if the requested node is completely unknown,
16141626
/// or if node announcement for the node was never received.

0 commit comments

Comments
 (0)