From: jbesraa Date: Mon, 20 Nov 2023 15:38:07 +0000 (+0200) Subject: Change `CandidateRouteHop` functions visbility X-Git-Tag: v0.0.119~25^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=04e93fc887bf6db34971037f2f7deae303995a2f;p=rust-lightning Change `CandidateRouteHop` functions visbility Change `short_channel_id`, `cltv_expiry_delta` `fees` and `htlc_minimum_msat` under `CandidateRouteHop` visibility to public and add documentation. --- diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 361d5793e..5e906878d 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1062,7 +1062,11 @@ pub enum CandidateRouteHop<'a> { } impl<'a> CandidateRouteHop<'a> { - fn short_channel_id(&self) -> Option { + /// 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 { 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,