From 731fa9d5f8ba4b718d8b8cb2ea7953b53680b23e 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 | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index 4e249a85c..d82ff1f4e 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -133,7 +133,7 @@ use bitcoin_hashes::sha256::Hash as Sha256; 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::{Payee, Route, RouteParameters}; use lightning::util::events::{Event, EventHandler}; use lightning::util::logger::Logger; @@ -150,16 +150,15 @@ use std::time::{Duration, SystemTime}; /// See [module-level documentation] for details. /// /// [module-level documentation]: crate::payment -pub struct InvoicePayer +pub struct InvoicePayer>, L: Deref, E: EventHandler> 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. @@ -220,11 +219,10 @@ pub enum PaymentError { Sending(PaymentSendFailure), } -impl InvoicePayer +impl>, L: Deref, E: EventHandler> InvoicePayer 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. @@ -232,7 +230,7 @@ where /// Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once /// `retry_attempts` has been exceeded for a given [`Invoice`]. pub fn new( - payer: P, router: R, scorer: S, logger: L, event_handler: E, retry_attempts: RetryAttempts + payer: P, router: R, scorer: SR, logger: L, event_handler: E, retry_attempts: RetryAttempts ) -> Self { Self { payer, @@ -453,11 +451,10 @@ fn has_expired(params: &RouteParameters) -> bool { } else { false } } -impl EventHandler for InvoicePayer +impl>, L: Deref, E: EventHandler> EventHandler for InvoicePayer 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