From: jbesraa Date: Tue, 5 Dec 2023 19:00:56 +0000 (+0200) Subject: Add `source` and `target` to `DirectedChannelInfo` X-Git-Tag: v0.0.119~25^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=366d68808734bab379072e2a069bd72da51f4421;p=rust-lightning Add `source` and `target` to `DirectedChannelInfo` `DirectedChannelInfo::source` return the `node_id` of the forwarding hop. `DirectedChannelInfo::target` return the `node_id` of the destination hop. --- diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs index 68bc7945a..edb372616 100644 --- a/lightning/src/routing/gossip.rs +++ b/lightning/src/routing/gossip.rs @@ -1043,6 +1043,16 @@ impl<'a> DirectedChannelInfo<'a> { /// Returns information for the direction. #[inline] pub(super) fn direction(&self) -> &'a ChannelUpdateInfo { self.direction } + + /// Returns the `node_id` of the source hop. + /// + /// Refers to the `node_id` forwarding the payment to the next hop. + pub(super) fn source(&self) -> &'a NodeId { if self.outbound { &self.channel.node_one } else { &self.channel.node_two } } + + /// Returns the `node_id` of the target hop. + /// + /// Refers to the `node_id` receiving the payment from the previous hop. + pub(super) fn target(&self) -> &'a NodeId { if self.outbound { &self.channel.node_two } else { &self.channel.node_one } } } impl<'a> fmt::Debug for DirectedChannelInfo<'a> {