@@ -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 ,
@@ -509,6 +522,8 @@ impl OutboundPayments {
509
522
hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
510
523
hash_map:: Entry :: Vacant ( entry) => {
511
524
let payment = entry. insert ( PendingOutboundPayment :: Retryable {
525
+ retry_strategy,
526
+ attempts : PaymentAttempts :: new ( ) ,
512
527
session_privs : HashSet :: new ( ) ,
513
528
pending_amt_msat : 0 ,
514
529
pending_fee_msat : Some ( 0 ) ,
@@ -910,7 +925,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
910
925
( 0 , session_privs, required) ,
911
926
( 1 , pending_fee_msat, option) ,
912
927
( 2 , payment_hash, required) ,
928
+ ( 3 , retry_strategy, ( reset_on_reload, Retry :: Attempts ( 0 ) ) ) ,
913
929
( 4 , payment_secret, option) ,
930
+ ( 5 , attempts, ( reset_on_reload, PaymentAttempts :: new( ) ) ) ,
914
931
( 6 , total_msat, required) ,
915
932
( 8 , pending_amt_msat, required) ,
916
933
( 10 , starting_block_height, required) ,
0 commit comments