@@ -92,7 +92,7 @@ type Balance = U256;
92
92
pub enum ReceiptFees {
93
93
NewReceipt ( u128 , u64 ) ,
94
94
UpdateValue ( UnaggregatedReceipts ) ,
95
- RavRequestResponse ( anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ) ,
95
+ RavRequestResponse ( ( UnaggregatedReceipts , anyhow:: Result < Option < SignedRAV > > ) ) ,
96
96
Retry ,
97
97
}
98
98
@@ -290,22 +290,18 @@ impl State {
290
290
fn finalize_rav_request (
291
291
& mut self ,
292
292
allocation_id : Address ,
293
- rav_result : anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ,
293
+ rav_response : ( UnaggregatedReceipts , anyhow:: Result < Option < SignedRAV > > ) ,
294
294
) {
295
295
self . sender_fee_tracker . finish_rav_request ( allocation_id) ;
296
+ let ( fees, rav_result) = rav_response;
296
297
match rav_result {
297
- Ok ( ( fees , rav ) ) => {
298
+ Ok ( signed_rav ) => {
298
299
self . sender_fee_tracker . ok_rav_request ( allocation_id) ;
299
300
self . adaptive_limiter . on_success ( ) ;
300
-
301
- let rav_value = rav. map_or ( 0 , |rav| rav. message . valueAggregate ) ;
301
+ let rav_value = signed_rav. map_or ( 0 , |rav| rav. message . valueAggregate ) ;
302
302
self . update_rav ( allocation_id, rav_value) ;
303
-
304
- // update sender fee tracker
305
- self . update_sender_fee ( allocation_id, fees) ;
306
303
}
307
304
Err ( err) => {
308
- // TODO we should update the total value too
309
305
self . sender_fee_tracker . failed_rav_backoff ( allocation_id) ;
310
306
self . adaptive_limiter . on_failure ( ) ;
311
307
error ! (
@@ -314,6 +310,7 @@ impl State {
314
310
) ;
315
311
}
316
312
} ;
313
+ self . update_sender_fee ( allocation_id, fees) ;
317
314
}
318
315
319
316
fn update_rav ( & mut self , allocation_id : Address , rav_value : u128 ) {
@@ -1102,8 +1099,10 @@ pub mod tests {
1102
1099
ReceiptFees :: RavRequestResponse ( l) ,
1103
1100
ReceiptFees :: RavRequestResponse ( r) ,
1104
1101
) => match ( l, r) {
1105
- ( Ok ( l) , Ok ( r) ) => l == r,
1106
- ( Err ( l) , Err ( r) ) => l. to_string ( ) == r. to_string ( ) ,
1102
+ ( ( fee, Ok ( rav) ) , ( fee1, Ok ( rav1) ) ) => fee == fee1 && rav == rav1,
1103
+ ( ( fee, Err ( error) ) , ( fee1, Err ( error1) ) ) => {
1104
+ fee == fee1 && error. to_string ( ) == error1. to_string ( )
1105
+ }
1107
1106
_ => false ,
1108
1107
} ,
1109
1108
( ReceiptFees :: Retry , ReceiptFees :: Retry ) => true ,
@@ -1534,14 +1533,14 @@ pub mod tests {
1534
1533
if let Some ( sender_account) = self . sender_actor . as_ref ( ) {
1535
1534
sender_account. cast ( SenderAccountMessage :: UpdateReceiptFees (
1536
1535
* ALLOCATION_ID_0 ,
1537
- ReceiptFees :: RavRequestResponse ( Ok ( (
1536
+ ReceiptFees :: RavRequestResponse ( (
1538
1537
UnaggregatedReceipts {
1539
1538
value : * self . next_unaggregated_fees_value . lock ( ) . unwrap ( ) ,
1540
1539
last_id : 0 ,
1541
1540
counter : 0 ,
1542
1541
} ,
1543
- Some ( signed_rav) ,
1544
- ) ) ) ,
1542
+ Ok ( Some ( signed_rav) ) ,
1543
+ ) ) ,
1545
1544
) ) ?;
1546
1545
}
1547
1546
}
0 commit comments