From: Jeffrey Czyz Date: Mon, 31 Jan 2022 21:00:33 +0000 (-0600) Subject: f - Unwrap inside DirectedChannelInfoWithUpdate X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1058b11348e4eebbbf67be0d510d3e9088980f18;p=rust-lightning f - Unwrap inside DirectedChannelInfoWithUpdate --- diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index ee0ca48a1..ff95b5d59 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -756,10 +756,17 @@ pub(super) struct DirectedChannelInfoWithUpdate<'a: 'b, 'b> { } impl<'a: 'b, 'b> DirectedChannelInfoWithUpdate<'a, 'b> { - /// Returns the underlying [`DirectedChannelInfo`]. - pub(super) fn inner(&self) -> &DirectedChannelInfo<'a, 'b> { - &self.inner - } + /// Returns information for the channel. + #[inline] + pub(super) fn channel(&self) -> &'a ChannelInfo { &self.inner.channel } + + /// Returns information for the direction. + #[inline] + pub(super) fn direction(&self) -> &'b ChannelUpdateInfo { self.inner.direction.unwrap() } + + /// Returns the [`EffectiveCapacity`] of the channel in the direction. + #[inline] + pub(super) fn effective_capacity(&self) -> EffectiveCapacity { self.inner.effective_capacity() } } /// The effective capacity of a channel for routing purposes. diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 671b4a127..835fc91c9 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -376,7 +376,7 @@ impl<'a> CandidateRouteHop<'a> { fn features(&self) -> ChannelFeatures { match self { CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(), - CandidateRouteHop::PublicHop { info, .. } => info.inner().channel().features.clone(), + CandidateRouteHop::PublicHop { info, .. } => info.channel().features.clone(), CandidateRouteHop::PrivateHop { .. } => ChannelFeatures::empty(), } } @@ -384,9 +384,7 @@ impl<'a> CandidateRouteHop<'a> { fn cltv_expiry_delta(&self) -> u32 { match self { CandidateRouteHop::FirstHop { .. } => 0, - CandidateRouteHop::PublicHop { info, .. } => { - info.inner().direction().unwrap().cltv_expiry_delta as u32 - }, + CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32, CandidateRouteHop::PrivateHop { hint } => hint.cltv_expiry_delta as u32, } } @@ -394,9 +392,7 @@ impl<'a> CandidateRouteHop<'a> { fn htlc_minimum_msat(&self) -> u64 { match self { CandidateRouteHop::FirstHop { .. } => 0, - CandidateRouteHop::PublicHop { info, .. } => { - info.inner().direction().unwrap().htlc_minimum_msat - }, + CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat, CandidateRouteHop::PrivateHop { hint } => hint.htlc_minimum_msat.unwrap_or(0), } } @@ -406,7 +402,7 @@ impl<'a> CandidateRouteHop<'a> { CandidateRouteHop::FirstHop { .. } => RoutingFees { base_msat: 0, proportional_millionths: 0, }, - CandidateRouteHop::PublicHop { info, .. } => info.inner().direction().unwrap().fees, + CandidateRouteHop::PublicHop { info, .. } => info.direction().fees, CandidateRouteHop::PrivateHop { hint } => hint.fees, } } @@ -416,7 +412,7 @@ impl<'a> CandidateRouteHop<'a> { CandidateRouteHop::FirstHop { details } => EffectiveCapacity::ExactLiquidity { liquidity_msat: details.outbound_capacity_msat, }, - CandidateRouteHop::PublicHop { info, .. } => info.inner().effective_capacity(), + CandidateRouteHop::PublicHop { info, .. } => info.effective_capacity(), CandidateRouteHop::PrivateHop { .. } => EffectiveCapacity::Infinite, } }