@@ -41,6 +41,8 @@ pub(crate) enum PendingOutboundPayment {
41
41
session_privs : HashSet < [ u8 ; 32 ] > ,
42
42
} ,
43
43
Retryable {
44
+ retry_strategy : Retry ,
45
+ attempts : PaymentAttempts ,
44
46
session_privs : HashSet < [ u8 ; 32 ] > ,
45
47
payment_hash : PaymentHash ,
46
48
payment_secret : Option < PaymentSecret > ,
@@ -74,6 +76,17 @@ pub(crate) enum PendingOutboundPayment {
74
76
}
75
77
76
78
impl PendingOutboundPayment {
79
+ fn increment_attempts ( & self ) {
80
+ if let PendingOutboundPayment :: Retryable { attempts, .. } = self {
81
+ attempts. count . fetch_add ( 1 , Ordering :: AcqRel ) ;
82
+ }
83
+ }
84
+ fn is_retryable ( & self ) -> bool {
85
+ if let PendingOutboundPayment :: Retryable { retry_strategy, attempts, .. } = self {
86
+ return retry_strategy. is_retryable_now ( & attempts)
87
+ }
88
+ false
89
+ }
77
90
pub ( super ) fn is_fulfilled ( & self ) -> bool {
78
91
match self {
79
92
PendingOutboundPayment :: Fulfilled { .. } => true ,
@@ -517,6 +530,8 @@ impl OutboundPayments {
517
530
hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
518
531
hash_map:: Entry :: Vacant ( entry) => {
519
532
let payment = entry. insert ( PendingOutboundPayment :: Retryable {
533
+ retry_strategy,
534
+ attempts : PaymentAttempts :: new ( ) ,
520
535
session_privs : HashSet :: new ( ) ,
521
536
pending_amt_msat : 0 ,
522
537
pending_fee_msat : Some ( 0 ) ,
@@ -920,7 +935,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
920
935
( 0 , session_privs, required) ,
921
936
( 1 , pending_fee_msat, option) ,
922
937
( 2 , payment_hash, required) ,
938
+ ( 3 , retry_strategy, ( static_value, Retry :: Attempts ( 0 ) ) ) ,
923
939
( 4 , payment_secret, option) ,
940
+ ( 5 , attempts, ( static_value, PaymentAttempts :: new( ) ) ) ,
924
941
( 6 , total_msat, required) ,
925
942
( 8 , pending_amt_msat, required) ,
926
943
( 10 , starting_block_height, required) ,
0 commit comments