Skip to content

Commit 366d688

Browse files
committed
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.
1 parent ec95e58 commit 366d688

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning/src/routing/gossip.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,16 @@ impl<'a> DirectedChannelInfo<'a> {
10431043
/// Returns information for the direction.
10441044
#[inline]
10451045
pub(super) fn direction(&self) -> &'a ChannelUpdateInfo { self.direction }
1046+
1047+
/// Returns the `node_id` of the source hop.
1048+
///
1049+
/// Refers to the `node_id` forwarding the payment to the next hop.
1050+
pub(super) fn source(&self) -> &'a NodeId { if self.outbound { &self.channel.node_one } else { &self.channel.node_two } }
1051+
1052+
/// Returns the `node_id` of the target hop.
1053+
///
1054+
/// Refers to the `node_id` receiving the payment from the previous hop.
1055+
pub(super) fn target(&self) -> &'a NodeId { if self.outbound { &self.channel.node_two } else { &self.channel.node_one } }
10461056
}
10471057

10481058
impl<'a> fmt::Debug for DirectedChannelInfo<'a> {

0 commit comments

Comments
 (0)