X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Fnetwork_graph.rs;h=fb90c9386dc3aa2bd6783a0993ea08bd7d2bd48d;hb=65436f5bc80e1dd25ebb3c48497b6c7220157003;hp=632754eae1b8fb85e8050256f678c249c47f3608;hpb=eb29be936c1fc10328a04c9bea343d45be7eda0f;p=rust-lightning diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 632754ea..fb90c938 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -660,19 +660,19 @@ pub struct ChannelInfo { } impl ChannelInfo { - /// Returns a [`DirectedChannelInfo`] for the channel directed to the given `target`, or `None` - /// if `target` is not one of the channel's counterparties. - pub fn as_directed_to(&self, target: &NodeId) -> Option { - let (direction, source, target) = { + /// Returns a [`DirectedChannelInfo`] for the channel directed to the given `target` from a + /// returned `source`, or `None` if `target` is not one of the channel's counterparties. + pub fn as_directed_to(&self, target: &NodeId) -> Option<(DirectedChannelInfo, &NodeId)> { + let (direction, source) = { if target == &self.node_one { - (self.two_to_one.as_ref(), &self.node_two, &self.node_one) + (self.two_to_one.as_ref(), &self.node_two) } else if target == &self.node_two { - (self.one_to_two.as_ref(), &self.node_one, &self.node_two) + (self.one_to_two.as_ref(), &self.node_one) } else { return None; } }; - Some(DirectedChannelInfo { channel: self, direction, source, target }) + Some((DirectedChannelInfo { channel: self, direction }, source)) } } @@ -701,8 +701,6 @@ impl_writeable_tlv_based!(ChannelInfo, { pub struct DirectedChannelInfo<'a> { channel: &'a ChannelInfo, direction: Option<&'a ChannelUpdateInfo>, - source: &'a NodeId, - target: &'a NodeId, } impl<'a> DirectedChannelInfo<'a> { @@ -712,12 +710,6 @@ impl<'a> DirectedChannelInfo<'a> { /// Returns information for the direction. pub fn direction(&self) -> Option<&'a ChannelUpdateInfo> { self.direction } - /// Returns the node id for the source. - pub fn source(&self) -> &'a NodeId { self.source } - - /// Returns the node id for the target. - pub fn target(&self) -> &'a NodeId { self.target } - /// Returns the [`EffectiveCapacity`] of the channel in the direction. /// /// This is either the total capacity from the funding transaction, if known, or the @@ -752,8 +744,6 @@ impl<'a> DirectedChannelInfo<'a> { impl<'a> fmt::Debug for DirectedChannelInfo<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { f.debug_struct("DirectedChannelInfo") - .field("source", &self.source) - .field("target", &self.target) .field("channel", &self.channel) .finish() }