@@ -40,6 +40,8 @@ pub(crate) enum PendingOutboundPayment {
40
40
session_privs : HashSet < [ u8 ; 32 ] > ,
41
41
} ,
42
42
Retryable {
43
+ retry_strategy : Retry ,
44
+ attempts : PaymentAttempts ,
43
45
session_privs : HashSet < [ u8 ; 32 ] > ,
44
46
payment_hash : PaymentHash ,
45
47
payment_secret : Option < PaymentSecret > ,
@@ -73,6 +75,17 @@ pub(crate) enum PendingOutboundPayment {
73
75
}
74
76
75
77
impl PendingOutboundPayment {
78
+ fn increment_attempts ( & mut self ) {
79
+ if let PendingOutboundPayment :: Retryable { attempts, .. } = self {
80
+ attempts. count += 1 ;
81
+ }
82
+ }
83
+ fn is_retryable ( & self ) -> bool {
84
+ if let PendingOutboundPayment :: Retryable { retry_strategy, attempts, .. } = self {
85
+ return retry_strategy. is_retryable_now ( & attempts)
86
+ }
87
+ false
88
+ }
76
89
pub ( super ) fn is_fulfilled ( & self ) -> bool {
77
90
match self {
78
91
PendingOutboundPayment :: Fulfilled { .. } => true ,
@@ -508,6 +521,8 @@ impl OutboundPayments {
508
521
hash_map:: Entry :: Occupied ( _) => Err ( PaymentSendFailure :: DuplicatePayment ) ,
509
522
hash_map:: Entry :: Vacant ( entry) => {
510
523
let payment = entry. insert ( PendingOutboundPayment :: Retryable {
524
+ retry_strategy,
525
+ attempts : PaymentAttempts :: new ( ) ,
511
526
session_privs : HashSet :: new ( ) ,
512
527
pending_amt_msat : 0 ,
513
528
pending_fee_msat : Some ( 0 ) ,
@@ -911,7 +926,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
911
926
( 0 , session_privs, required) ,
912
927
( 1 , pending_fee_msat, option) ,
913
928
( 2 , payment_hash, required) ,
929
+ ( not_written, retry_strategy, ( static_value, Retry :: Attempts ( 0 ) ) ) ,
914
930
( 4 , payment_secret, option) ,
931
+ ( not_written, attempts, ( static_value, PaymentAttempts :: new( ) ) ) ,
915
932
( 6 , total_msat, required) ,
916
933
( 8 , pending_amt_msat, required) ,
917
934
( 10 , starting_block_height, required) ,
0 commit comments