@@ -187,6 +187,36 @@ impl PendingOutboundPayment {
187
187
}
188
188
}
189
189
190
+ /// Strategies available to retry payment path failures.
191
+ #[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
192
+ pub enum Retry {
193
+ /// Max number of attempts to retry payment.
194
+ ///
195
+ /// Note that this is the number of *path* failures, not full payment retries. For multi-path
196
+ /// payments, if this is less than the total number of paths, we will never even retry all of the
197
+ /// payment's paths.
198
+ Attempts ( usize ) ,
199
+ #[ cfg( not( feature = "no-std" ) ) ]
200
+ /// Time elapsed before abandoning retries for a payment.
201
+ Timeout ( core:: time:: Duration ) ,
202
+ }
203
+
204
+ impl Retry {
205
+ pub ( crate ) fn is_retryable_now ( & self , attempts : & PaymentAttempts ) -> bool {
206
+ match ( self , attempts) {
207
+ ( Retry :: Attempts ( max_retry_count) , PaymentAttempts { count, .. } ) => {
208
+ max_retry_count > count
209
+ } ,
210
+ #[ cfg( all( not( feature = "no-std" ) , not( test) ) ) ]
211
+ ( Retry :: Timeout ( max_duration) , PaymentAttempts { first_attempted_at, .. } ) =>
212
+ * max_duration >= std:: time:: Instant :: now ( ) . duration_since ( * first_attempted_at) ,
213
+ #[ cfg( all( not( feature = "no-std" ) , test) ) ]
214
+ ( Retry :: Timeout ( max_duration) , PaymentAttempts { first_attempted_at, .. } ) =>
215
+ * max_duration >= SinceEpoch :: now ( ) . duration_since ( * first_attempted_at) ,
216
+ }
217
+ }
218
+ }
219
+
190
220
pub ( crate ) type PaymentAttempts = PaymentAttemptsUsingTime < ConfiguredTime > ;
191
221
192
222
/// Storing minimal payment attempts information required for determining if a outbound payment can
0 commit comments