Skip to content

Commit 728a609

Browse files
author
Antoine Riard
committed
Expose ChannelInfo through list_edges
Make ChannelInfo and its fields public.
1 parent b61ce53 commit 728a609

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

lightning/src/ln/router.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,22 @@ impl Readable for Route {
9191
}
9292
}
9393

94-
#[derive(PartialEq)]
95-
struct DirectionalChannelInfo {
94+
/// Details of channel routing parameters for one-direction, as stored in ChannelInfo
95+
#[derive(Clone, PartialEq)]
96+
pub struct DirectionalChannelInfo {
97+
/// node_id
9698
src_node_id: PublicKey,
99+
/// last update on channel state sent by node_id
97100
last_update: u32,
101+
/// channel readiness as assess by node_id
98102
enabled: bool,
103+
/// CLTV delta added by node_id for an outgoing HTLC
99104
cltv_expiry_delta: u16,
105+
/// Minimum outgoing HLTC value
100106
htlc_minimum_msat: u64,
107+
/// Minimum fee payed on outgoing HTLC
101108
fee_base_msat: u32,
109+
/// Proportional fee payed on outgoing HTLC
102110
fee_proportional_millionths: u32,
103111
last_update_message: Option<msgs::ChannelUpdate>,
104112
}
@@ -121,12 +129,17 @@ impl_writeable!(DirectionalChannelInfo, 0, {
121129
last_update_message
122130
});
123131

124-
#[derive(PartialEq)]
125-
struct ChannelInfo {
126-
short_channel_id: u64,
127-
features: ChannelFeatures,
128-
one_to_two: DirectionalChannelInfo,
129-
two_to_one: DirectionalChannelInfo,
132+
/// Details of a channel, as stored in NetworkMap and returned by Router::list_edges
133+
#[derive(Clone, PartialEq)]
134+
pub struct ChannelInfo {
135+
/// The short_channel_id of this channel
136+
pub short_channel_id: u64,
137+
/// The channel features
138+
pub features: ChannelFeatures,
139+
/// Alice to Bob channel routing parameters
140+
pub one_to_two: DirectionalChannelInfo,
141+
/// Bob to Alice channel routing parameters
142+
pub two_to_one: DirectionalChannelInfo,
130143
//this is cached here so we can send out it later if required by route_init_sync
131144
//keep an eye on this to see if the extra memory is a problem
132145
announcement_message: Option<msgs::ChannelAnnouncement>,
@@ -1060,6 +1073,17 @@ impl Router {
10601073

10611074
Err(LightningError{err: "Failed to find a path to the given destination", action: ErrorAction::IgnoreError})
10621075
}
1076+
1077+
/// Gets the list of announced channels, in random order. See ChannelInfo details field documentation for more information
1078+
pub fn list_edges(&self) -> Vec<ChannelInfo> {
1079+
let mut edges = Vec::new();
1080+
let network = self.network_map.read().unwrap();
1081+
edges.reserve(network.channels.len());
1082+
for (_, chan) in network.channels.iter() {
1083+
edges.push((*chan).clone());
1084+
}
1085+
edges
1086+
}
10631087
}
10641088

10651089
#[cfg(test)]

0 commit comments

Comments
 (0)