Remove unused payment_hash param from Router::find_route
authorValentine Wallace <vwallace@protonmail.com>
Tue, 25 Oct 2022 00:17:03 +0000 (20:17 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 27 Oct 2022 22:02:12 +0000 (18:02 -0400)
This helps prepare for moving the Router trait into ChannelManager, which will
help allow ChannelManager to retrieve routes for trampoline

lightning-invoice/src/payment.rs
lightning-invoice/src/utils.rs

index 1b3177adfae20a0243bdc30c0091d29d6633177b..d46024c92f1ce29a2986b0934e3e2393dba3f316 100644 (file)
@@ -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<Route, LightningError> { 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<Route, LightningError>;
        /// 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, &params, &payment_hash, Some(&first_hops.iter().collect::<Vec<_>>()),
-                       inflight_htlcs
+                       &payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), 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, &params, &payment_hash, Some(&first_hops.iter().collect::<Vec<_>>()),
-                       inflight_htlcs
+                       &payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), 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<Route, LightningError> {
                        // 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<Route, LightningError> {
                        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<Route, LightningError> {
                        self.0.borrow_mut().pop_front().unwrap()
                }
index 8b45d5805c91e1a9128b75ee326efba184e8fd48..4d5d98f87d78ca3f3ae39598c4a74588fd7db685 100644 (file)
@@ -552,8 +552,8 @@ impl<G: Deref<Target = NetworkGraph<L>>, 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<Route, LightningError> {
                let random_seed_bytes = {
                        let mut locked_random_seed_bytes = self.random_seed_bytes.lock().unwrap();