Skip to content

Commit dc7f65f

Browse files
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
1 parent 59e24bd commit dc7f65f

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

lightning-invoice/src/payment.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
//! # struct FakeRouter {}
7474
//! # impl Router for FakeRouter {
7575
//! # fn find_route(
76-
//! # &self, payer: &PublicKey, params: &RouteParameters, payment_hash: &PaymentHash,
76+
//! # &self, payer: &PublicKey, params: &RouteParameters,
7777
//! # first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
7878
//! # ) -> Result<Route, LightningError> { unimplemented!() }
7979
//! #
@@ -270,7 +270,7 @@ pub trait Payer {
270270
pub trait Router {
271271
/// Finds a [`Route`] between `payer` and `payee` for a payment with the given values.
272272
fn find_route(
273-
&self, payer: &PublicKey, route_params: &RouteParameters, payment_hash: &PaymentHash,
273+
&self, payer: &PublicKey, route_params: &RouteParameters,
274274
first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs
275275
) -> Result<Route, LightningError>;
276276
/// Lets the router know that payment through a specific path has failed.
@@ -447,8 +447,7 @@ where
447447
let first_hops = self.payer.first_hops();
448448
let inflight_htlcs = self.create_inflight_map();
449449
let route = self.router.find_route(
450-
&payer, &params, &payment_hash, Some(&first_hops.iter().collect::<Vec<_>>()),
451-
inflight_htlcs
450+
&payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
452451
).map_err(|e| PaymentError::Routing(e))?;
453452

454453
match send_payment(&route) {
@@ -552,8 +551,7 @@ where
552551
let inflight_htlcs = self.create_inflight_map();
553552

554553
let route = self.router.find_route(
555-
&payer, &params, &payment_hash, Some(&first_hops.iter().collect::<Vec<_>>()),
556-
inflight_htlcs
554+
&payer, &params, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
557555
);
558556

559557
if route.is_err() {
@@ -1812,7 +1810,7 @@ mod tests {
18121810

18131811
impl Router for TestRouter {
18141812
fn find_route(
1815-
&self, payer: &PublicKey, route_params: &RouteParameters, _payment_hash: &PaymentHash,
1813+
&self, payer: &PublicKey, route_params: &RouteParameters,
18161814
_first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs
18171815
) -> Result<Route, LightningError> {
18181816
// Simulate calling the Scorer just as you would in find_route
@@ -1865,8 +1863,8 @@ mod tests {
18651863

18661864
impl Router for FailingRouter {
18671865
fn find_route(
1868-
&self, _payer: &PublicKey, _params: &RouteParameters, _payment_hash: &PaymentHash,
1869-
_first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
1866+
&self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>,
1867+
_inflight_htlcs: InFlightHtlcs
18701868
) -> Result<Route, LightningError> {
18711869
Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError })
18721870
}
@@ -2127,8 +2125,8 @@ mod tests {
21272125

21282126
impl Router for ManualRouter {
21292127
fn find_route(
2130-
&self, _payer: &PublicKey, _params: &RouteParameters, _payment_hash: &PaymentHash,
2131-
_first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs
2128+
&self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>,
2129+
_inflight_htlcs: InFlightHtlcs
21322130
) -> Result<Route, LightningError> {
21332131
self.0.borrow_mut().pop_front().unwrap()
21342132
}

lightning-invoice/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, S: Deref> Router for DefaultR
552552
S::Target: for <'a> LockableScore<'a>,
553553
{
554554
fn find_route(
555-
&self, payer: &PublicKey, params: &RouteParameters, _payment_hash: &PaymentHash,
556-
first_hops: Option<&[&ChannelDetails]>, inflight_htlcs: InFlightHtlcs
555+
&self, payer: &PublicKey, params: &RouteParameters, first_hops: Option<&[&ChannelDetails]>,
556+
inflight_htlcs: InFlightHtlcs
557557
) -> Result<Route, LightningError> {
558558
let random_seed_bytes = {
559559
let mut locked_random_seed_bytes = self.random_seed_bytes.lock().unwrap();

0 commit comments

Comments
 (0)