From f49c74ae10b69a40fa1cbf40959fe62c79ee317e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 17 Dec 2021 22:32:24 +0000 Subject: [PATCH] (Bindings Only) Concretize LockableScore as MultiThreadedLockableScore We don't really care about more than this in bindings - calling into a custom `Score` is likely too slow to be practical anyway, so this is also a performance improvement. Works around https://github.com/rust-lang/rust/issues/90448 --- lightning-invoice/src/payment.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index e672b89c9..984d9db16 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -142,7 +142,7 @@ use crate::prelude::*; use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure}; use lightning::ln::msgs::LightningError; -use lightning::routing::scoring::{LockableScore, Score}; +use lightning::routing::scoring::{LockableScore, MultiThreadedLockableScore, Score}; use lightning::routing::router::{PaymentParameters, Route, RouteParameters}; use lightning::util::events::{Event, EventHandler}; use lightning::util::logger::Logger; @@ -163,7 +163,7 @@ use std::time::SystemTime; /// See [module-level documentation] for details. /// /// [module-level documentation]: crate::payment -pub type InvoicePayer = InvoicePayerUsingTime::; +pub type InvoicePayer = InvoicePayerUsingTime::; #[cfg(not(feature = "no-std"))] type ConfiguredTime = std::time::Instant; @@ -173,16 +173,15 @@ use time_utils; type ConfiguredTime = time_utils::Eternity; /// (C-not exported) generally all users should use the [`InvoicePayer`] type alias. -pub struct InvoicePayerUsingTime +pub struct InvoicePayerUsingTime>, L: Deref, E: EventHandler, T: Time> where P::Target: Payer, - R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, - S::Target: for <'a> LockableScore<'a>, + R::Target: Router, L::Target: Logger, { payer: P, router: R, - scorer: S, + scorer: SR, logger: L, event_handler: E, /// Caches the overall attempts at making a payment, which is updated prior to retrying. @@ -297,11 +296,10 @@ pub enum PaymentError { Sending(PaymentSendFailure), } -impl InvoicePayerUsingTime +impl>, L: Deref, E: EventHandler, T: Time> InvoicePayerUsingTime where P::Target: Payer, - R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, - S::Target: for <'a> LockableScore<'a>, + R::Target: Router, L::Target: Logger, { /// Creates an invoice payer that retries failed payment paths. @@ -309,7 +307,7 @@ where /// Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once /// `retry` has been exceeded for a given [`Invoice`]. pub fn new( - payer: P, router: R, scorer: S, logger: L, event_handler: E, retry: Retry + payer: P, router: R, scorer: SR, logger: L, event_handler: E, retry: Retry ) -> Self { Self { payer, @@ -538,11 +536,10 @@ fn has_expired(route_params: &RouteParameters) -> bool { } else { false } } -impl EventHandler for InvoicePayerUsingTime +impl>, L: Deref, E: EventHandler, T: Time> EventHandler for InvoicePayerUsingTime where P::Target: Payer, - R: for <'a> Router<<::Target as LockableScore<'a>>::Locked>, - S::Target: for <'a> LockableScore<'a>, + R::Target: Router, L::Target: Logger, { fn handle_event(&self, event: &Event) { -- 2.39.5