]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Change `CandidateRouteHop` functions visbility
authorjbesraa <jbesraa@gmail.com>
Mon, 20 Nov 2023 15:38:07 +0000 (17:38 +0200)
committerjbesraa <jbesraa@gmail.com>
Tue, 5 Dec 2023 19:07:47 +0000 (21:07 +0200)
  Change `short_channel_id`, `cltv_expiry_delta`
  `fees` and `htlc_minimum_msat` under `CandidateRouteHop` visibility
  to public and add documentation.

lightning/src/routing/router.rs

index 361d5793edcc5e27980b34b93737ce608d6f2103..5e906878d082b851d831b19fee2fa4bb5321f9d1 100644 (file)
@@ -1062,7 +1062,11 @@ pub enum CandidateRouteHop<'a> {
 }
 
 impl<'a> CandidateRouteHop<'a> {
-       fn short_channel_id(&self) -> Option<u64> {
+       /// Returns short_channel_id if known.
+       /// For `FirstHop` we assume [`ChannelDetails::get_outbound_payment_scid`] is always set, this assumption is checked in
+       /// [`find_route`] method.
+       /// For `Blinded` and `OneHopBlinded` we return `None` because next hop is not known.
+       pub fn short_channel_id(&self) -> Option<u64> {
                match self {
                        CandidateRouteHop::FirstHop { details, .. } => Some(details.get_outbound_payment_scid().unwrap()),
                        CandidateRouteHop::PublicHop { short_channel_id, .. } => Some(*short_channel_id),
@@ -1083,7 +1087,8 @@ impl<'a> CandidateRouteHop<'a> {
                }
        }
 
-       fn cltv_expiry_delta(&self) -> u32 {
+       /// Returns cltv_expiry_delta for this hop.
+       pub fn cltv_expiry_delta(&self) -> u32 {
                match self {
                        CandidateRouteHop::FirstHop { .. } => 0,
                        CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
@@ -1093,7 +1098,8 @@ impl<'a> CandidateRouteHop<'a> {
                }
        }
 
-       fn htlc_minimum_msat(&self) -> u64 {
+       /// Returns the htlc_minimum_msat for this hop.
+       pub fn htlc_minimum_msat(&self) -> u64 {
                match self {
                        CandidateRouteHop::FirstHop { details, .. } => details.next_outbound_htlc_minimum_msat,
                        CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
@@ -1103,7 +1109,8 @@ impl<'a> CandidateRouteHop<'a> {
                }
        }
 
-       fn fees(&self) -> RoutingFees {
+       /// Returns the fees for this hop.
+       pub fn fees(&self) -> RoutingFees {
                match self {
                        CandidateRouteHop::FirstHop { .. } => RoutingFees {
                                base_msat: 0, proportional_millionths: 0,