WTF is an HRTB 1144-magic
authorMatt Corallo <git@bluematt.me>
Thu, 28 Oct 2021 15:39:01 +0000 (15:39 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 28 Oct 2021 15:39:01 +0000 (15:39 +0000)
lightning-invoice/src/payment.rs
lightning/src/routing/mod.rs

index fe6a25f1aafdb7bd1e6579eb490c1d0b8bb855b1..66a54d34f838118d2704f557b07415e116918cda 100644 (file)
@@ -131,11 +131,11 @@ use std::sync::Mutex;
 use std::time::{Duration, SystemTime};
 
 /// A utility for paying [`Invoice]`s.
-pub struct InvoicePayer<'a: 'b, 'b, P: Deref, R, S, L: Deref, E>
+pub struct InvoicePayer<P: Deref, R, S, L: Deref, E>
 where
        P::Target: Payer,
        R: Router,
-       S: routing::LockableScore<'a, 'b>,
+       S: for <'b> routing::LockableScore<'b>,
        L::Target: Logger,
        E: EventHandler,
 {
@@ -146,7 +146,6 @@ where
        event_handler: E,
        payment_cache: Mutex<HashMap<PaymentHash, usize>>,
        retry_attempts: RetryAttempts,
-       phantom: std::marker::PhantomData<(&'a (), &'b ())>,
 }
 
 /// A trait defining behavior of an [`Invoice`] payer.
@@ -190,11 +189,11 @@ pub enum PaymentError {
        Sending(PaymentSendFailure),
 }
 
-impl<'a: 'b, 'b, P: Deref, R, S, L: Deref, E> InvoicePayer<'a, 'b, P, R, S, L, E>
+impl<P: Deref, R, S, L: Deref, E> InvoicePayer<P, R, S, L, E>
 where
        P::Target: Payer,
        R: Router,
-       S: routing::LockableScore<'a, 'b>,
+       S: for <'b> routing::LockableScore<'b>,
        L::Target: Logger,
        E: EventHandler,
 {
@@ -213,7 +212,6 @@ where
                        event_handler,
                        payment_cache: Mutex::new(HashMap::new()),
                        retry_attempts,
-                       phantom: std::marker::PhantomData,
                }
        }
 
@@ -307,11 +305,11 @@ fn has_expired(params: &RouteParameters) -> bool {
        Invoice::is_expired_from_epoch(&SystemTime::UNIX_EPOCH, expiry_time)
 }
 
-impl<'a: 'b, 'b, P: Deref, R, S, L: Deref, E> EventHandler for InvoicePayer<'a, 'b, P, R, S, L, E>
+impl<P: Deref, R, S, L: Deref, E> EventHandler for InvoicePayer<P, R, S, L, E>
 where
        P::Target: Payer,
        R: Router,
-       S: routing::LockableScore<'a, 'b>,
+       S: for <'b> routing::LockableScore<'b>,
        L::Target: Logger,
        E: EventHandler,
 {
index 4c5469c5f15f10acc543bcd6d7cb0f907d1c5fd3..faee7854086ae5d7d42174c9ed20542798ab5b6a 100644 (file)
@@ -32,16 +32,17 @@ pub trait Score {
        fn payment_path_failed(&mut self, path: &Vec<RouteHop>, short_channel_id: u64);
 }
 
-pub trait LockableScore<'a: 'b, 'b> {
-       type Locked: Score;
-
-       fn lock(&'a self) -> Self::Locked;
+///
+pub trait LockableScore<'b> {
+       ///
+       type Locked: Score + 'b;
+       ///
+       fn lock(&'b self) -> Self::Locked;
 }
 
-impl<'a: 'b, 'b, S: 'b + Score, T: Deref<Target=Mutex<S>>> LockableScore<'a, 'b> for T {
+impl<'b, S: Score + 'b, T: Deref<Target=Mutex<S>>> LockableScore<'b> for T {
        type Locked = MutexGuard<'b, S>;
-
-       fn lock(&'a self) -> Self::Locked {
+       fn lock(&'b self) -> MutexGuard<'b, S> {
                self.deref().lock().unwrap()
        }
 }