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