@@ -990,54 +990,38 @@ impl Readable for ChannelInfo {
990
990
pub struct DirectedChannelInfo < ' a > {
991
991
channel : & ' a ChannelInfo ,
992
992
direction : & ' a ChannelUpdateInfo ,
993
- htlc_maximum_msat : u64 ,
994
- effective_capacity : EffectiveCapacity ,
995
- /// Outbound from the perspective of `node_one`.
996
- ///
997
- /// If true, the channel is considered to be outbound from `node_one` perspective.
998
- /// If false, the channel is considered to be outbound from `node_two` perspective.
999
- ///
1000
- /// [`ChannelInfo::node_one`]
1001
- /// [`ChannelInfo::node_two`]
1002
- outbound : bool ,
993
+ /// The direction this channel is in - if set, it indicates that we're traversing the channel
994
+ /// from [`ChannelInfo::node_one`] to [`ChannelInfo::node_two`].
995
+ from_node_one : bool ,
1003
996
}
1004
997
1005
998
impl < ' a > DirectedChannelInfo < ' a > {
1006
999
#[ inline]
1007
- fn new ( channel : & ' a ChannelInfo , direction : & ' a ChannelUpdateInfo , outbound : bool ) -> Self {
1008
- let mut htlc_maximum_msat = direction. htlc_maximum_msat ;
1009
- let capacity_msat = channel. capacity_sats . map ( |capacity_sats| capacity_sats * 1000 ) ;
1010
-
1011
- let effective_capacity = match capacity_msat {
1012
- Some ( capacity_msat) => {
1013
- htlc_maximum_msat = cmp:: min ( htlc_maximum_msat, capacity_msat) ;
1014
- EffectiveCapacity :: Total { capacity_msat, htlc_maximum_msat }
1015
- } ,
1016
- None => EffectiveCapacity :: AdvertisedMaxHTLC { amount_msat : htlc_maximum_msat } ,
1017
- } ;
1018
-
1019
- Self {
1020
- channel, direction, htlc_maximum_msat, effective_capacity, outbound
1021
- }
1000
+ fn new ( channel : & ' a ChannelInfo , direction : & ' a ChannelUpdateInfo , from_node_one : bool ) -> Self {
1001
+ Self { channel, direction, from_node_one }
1022
1002
}
1023
1003
1024
1004
/// Returns information for the channel.
1025
1005
#[ inline]
1026
1006
pub fn channel ( & self ) -> & ' a ChannelInfo { self . channel }
1027
1007
1028
- /// Returns the maximum HTLC amount allowed over the channel in the direction.
1029
- #[ inline]
1030
- pub fn htlc_maximum_msat ( & self ) -> u64 {
1031
- self . htlc_maximum_msat
1032
- }
1033
-
1034
1008
/// Returns the [`EffectiveCapacity`] of the channel in the direction.
1035
1009
///
1036
1010
/// This is either the total capacity from the funding transaction, if known, or the
1037
1011
/// `htlc_maximum_msat` for the direction as advertised by the gossip network, if known,
1038
1012
/// otherwise.
1013
+ #[ inline]
1039
1014
pub fn effective_capacity ( & self ) -> EffectiveCapacity {
1040
- self . effective_capacity
1015
+ let mut htlc_maximum_msat = self . direction ( ) . htlc_maximum_msat ;
1016
+ let capacity_msat = self . channel . capacity_sats . map ( |capacity_sats| capacity_sats * 1000 ) ;
1017
+
1018
+ match capacity_msat {
1019
+ Some ( capacity_msat) => {
1020
+ htlc_maximum_msat = cmp:: min ( htlc_maximum_msat, capacity_msat) ;
1021
+ EffectiveCapacity :: Total { capacity_msat, htlc_maximum_msat }
1022
+ } ,
1023
+ None => EffectiveCapacity :: AdvertisedMaxHTLC { amount_msat : htlc_maximum_msat } ,
1024
+ }
1041
1025
}
1042
1026
1043
1027
/// Returns information for the direction.
@@ -1047,12 +1031,14 @@ impl<'a> DirectedChannelInfo<'a> {
1047
1031
/// Returns the `node_id` of the source hop.
1048
1032
///
1049
1033
/// 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 } }
1034
+ #[ inline]
1035
+ pub ( super ) fn source ( & self ) -> & ' a NodeId { if self . from_node_one { & self . channel . node_one } else { & self . channel . node_two } }
1051
1036
1052
1037
/// Returns the `node_id` of the target hop.
1053
1038
///
1054
1039
/// 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 } }
1040
+ #[ inline]
1041
+ pub ( super ) fn target ( & self ) -> & ' a NodeId { if self . from_node_one { & self . channel . node_two } else { & self . channel . node_one } }
1056
1042
}
1057
1043
1058
1044
impl < ' a > fmt:: Debug for DirectedChannelInfo < ' a > {
0 commit comments