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=d9e1ff81ad1007ed6646b1e45e3af1b2f583ae9b;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 051893ea0..fc9daf809 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -144,7 +144,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; @@ -165,7 +165,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; @@ -175,16 +175,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. @@ -299,11 +298,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. @@ -311,7 +309,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, @@ -540,11 +538,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) {