X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Fnetwork_graph.rs;fp=lightning%2Fsrc%2Frouting%2Fnetwork_graph.rs;h=a5e497bb1cf0f279137fd3f5e923e8972317181d;hb=e92b5a7ebd6edcf1da6e8e1d3ed34f5cf20bffaf;hp=5a84f35c28dd4f1990ef0eda4611c53a139cb615;hpb=1a734492d955e61d43eab4407dd65f556e87ca96;p=rust-lightning diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 5a84f35c..a5e497bb 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -674,6 +674,21 @@ impl ChannelInfo { }; Some((DirectedChannelInfo { channel: self, direction }, source)) } + + /// Returns a [`DirectedChannelInfo`] for the channel directed from the given `source` to a + /// returned `target`, or `None` if `source` is not one of the channel's counterparties. + pub fn as_directed_from(&self, source: &NodeId) -> Option<(DirectedChannelInfo, &NodeId)> { + let (direction, target) = { + if source == &self.node_one { + (self.one_to_two.as_ref(), &self.node_two) + } else if source == &self.node_two { + (self.two_to_one.as_ref(), &self.node_one) + } else { + return None; + } + }; + Some((DirectedChannelInfo { channel: self, direction }, target)) + } } impl fmt::Display for ChannelInfo {