From: Matt Corallo Date: Fri, 17 Dec 2021 22:32:24 +0000 (+0000) Subject: (Bindings Only) Concretize LockableScore as MultiThreadedLockableScore X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=159fae7ef7a9f0aea7f992c89186f305ed52ac3c;p=rust-lightning (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 --- diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index 82c07199f..c9553711c 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; @@ -160,16 +160,15 @@ use std::time::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. @@ -230,11 +229,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. @@ -242,7 +240,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, @@ -468,11 +466,10 @@ fn has_expired(route_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) {