//! # 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!() }
//! #
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.
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::<Vec<_>>()),
- inflight_htlcs
+ &payer, ¶ms, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
).map_err(|e| PaymentError::Routing(e))?;
match send_payment(&route) {
let inflight_htlcs = self.create_inflight_map();
let route = self.router.find_route(
- &payer, ¶ms, &payment_hash, Some(&first_hops.iter().collect::<Vec<_>>()),
- inflight_htlcs
+ &payer, ¶ms, Some(&first_hops.iter().collect::<Vec<_>>()), inflight_htlcs
);
if route.is_err() {
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
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 })
}
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()
}