@@ -990,54 +990,38 @@ impl Readable for ChannelInfo {
990990pub struct DirectedChannelInfo < ' a > {
991991 channel : & ' a ChannelInfo ,
992992 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 ,
1003996}
1004997
1005998impl < ' a > DirectedChannelInfo < ' a > {
1006999 #[ 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 }
10221002 }
10231003
10241004 /// Returns information for the channel.
10251005 #[ inline]
10261006 pub fn channel ( & self ) -> & ' a ChannelInfo { self . channel }
10271007
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-
10341008 /// Returns the [`EffectiveCapacity`] of the channel in the direction.
10351009 ///
10361010 /// This is either the total capacity from the funding transaction, if known, or the
10371011 /// `htlc_maximum_msat` for the direction as advertised by the gossip network, if known,
10381012 /// otherwise.
1013+ #[ inline]
10391014 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+ }
10411025 }
10421026
10431027 /// Returns information for the direction.
@@ -1047,12 +1031,14 @@ impl<'a> DirectedChannelInfo<'a> {
10471031 /// Returns the `node_id` of the source hop.
10481032 ///
10491033 /// 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 } }
10511036
10521037 /// Returns the `node_id` of the target hop.
10531038 ///
10541039 /// 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 } }
10561042}
10571043
10581044impl < ' a > fmt:: Debug for DirectedChannelInfo < ' a > {
0 commit comments