From: Valentine Wallace Date: Tue, 25 Oct 2022 00:17:03 +0000 (-0400) Subject: Remove unused payment_hash param from Router::find_route X-Git-Tag: v0.0.113~57^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=dc7f65f703301f2125c1dd1e656272e5d0005b40;p=rust-lightning Remove unused payment_hash param from Router::find_route This helps prepare for moving the Router trait into ChannelManager, which will help allow ChannelManager to retrieve routes for trampoline --- diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index 1b3177adf..d46024c92 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -73,7 +73,7 @@ //! # struct FakeRouter {} //! # impl Router for FakeRouter { //! # fn find_route( -//! # &self, payer: &PublicKey, params: &RouteParameters, payment_hash: &PaymentHash, +//! # &self, payer: &PublicKey, params: &RouteParameters, //! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs //! # ) -> Result { unimplemented!() } //! # @@ -270,7 +270,7 @@ pub trait Payer { pub trait Router { /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. fn find_route( - &self, payer: &PublicKey, route_params: &RouteParameters, payment_hash: &PaymentHash, + &self, payer: &PublicKey, route_params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs ) -> Result; /// Lets the router know that payment through a specific path has failed. @@ -447,8 +447,7 @@ where let first_hops = self.payer.first_hops(); let inflight_htlcs = self.create_inflight_map(); let route = self.router.find_route( - &payer, ¶ms, &payment_hash, Some(&first_hops.iter().collect::>()), - inflight_htlcs + &payer, ¶ms, Some(&first_hops.iter().collect::>()), inflight_htlcs ).map_err(|e| PaymentError::Routing(e))?; match send_payment(&route) { @@ -552,8 +551,7 @@ where let inflight_htlcs = self.create_inflight_map(); let route = self.router.find_route( - &payer, ¶ms, &payment_hash, Some(&first_hops.iter().collect::>()), - inflight_htlcs + &payer, ¶ms, Some(&first_hops.iter().collect::>()), inflight_htlcs ); if route.is_err() { @@ -1812,7 +1810,7 @@ mod tests { impl Router for TestRouter { fn find_route( - &self, payer: &PublicKey, route_params: &RouteParameters, _payment_hash: &PaymentHash, + &self, payer: &PublicKey, route_params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs ) -> Result { // Simulate calling the Scorer just as you would in find_route @@ -1865,8 +1863,8 @@ mod tests { impl Router for FailingRouter { fn find_route( - &self, _payer: &PublicKey, _params: &RouteParameters, _payment_hash: &PaymentHash, - _first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs + &self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>, + _inflight_htlcs: InFlightHtlcs ) -> Result { Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError }) } @@ -2127,8 +2125,8 @@ mod tests { impl Router for ManualRouter { fn find_route( - &self, _payer: &PublicKey, _params: &RouteParameters, _payment_hash: &PaymentHash, - _first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs + &self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>, + _inflight_htlcs: InFlightHtlcs ) -> Result { self.0.borrow_mut().pop_front().unwrap() } diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index 8b45d5805..4d5d98f87 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -552,8 +552,8 @@ impl>, L: Deref, S: Deref> Router for DefaultR S::Target: for <'a> LockableScore<'a>, { fn find_route( - &self, payer: &PublicKey, params: &RouteParameters, _payment_hash: &PaymentHash, - first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs + &self, payer: &PublicKey, params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>, + inflight_htlcs: InFlightHtlcs ) -> Result { let random_seed_bytes = { let mut locked_random_seed_bytes = self.random_seed_bytes.lock().unwrap();