@@ -92,7 +92,7 @@ type Balance = U256;
9292pub enum ReceiptFees {
9393 NewReceipt ( u128 , u64 ) ,
9494 UpdateValue ( UnaggregatedReceipts ) ,
95- RavRequestResponse ( anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ) ,
95+ RavRequestResponse ( ( UnaggregatedReceipts , anyhow:: Result < Option < SignedRAV > > ) ) ,
9696 Retry ,
9797}
9898
@@ -290,22 +290,18 @@ impl State {
290290 fn finalize_rav_request (
291291 & mut self ,
292292 allocation_id : Address ,
293- rav_result : anyhow:: Result < ( UnaggregatedReceipts , Option < SignedRAV > ) > ,
293+ rav_response : ( UnaggregatedReceipts , anyhow:: Result < Option < SignedRAV > > ) ,
294294 ) {
295295 self . sender_fee_tracker . finish_rav_request ( allocation_id) ;
296+ let ( fees, rav_result) = rav_response;
296297 match rav_result {
297- Ok ( ( fees , rav ) ) => {
298+ Ok ( signed_rav ) => {
298299 self . sender_fee_tracker . ok_rav_request ( allocation_id) ;
299300 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 ) ;
302302 self . update_rav ( allocation_id, rav_value) ;
303-
304- // update sender fee tracker
305- self . update_sender_fee ( allocation_id, fees) ;
306303 }
307304 Err ( err) => {
308- // TODO we should update the total value too
309305 self . sender_fee_tracker . failed_rav_backoff ( allocation_id) ;
310306 self . adaptive_limiter . on_failure ( ) ;
311307 error ! (
@@ -314,6 +310,7 @@ impl State {
314310 ) ;
315311 }
316312 } ;
313+ self . update_sender_fee ( allocation_id, fees) ;
317314 }
318315
319316 fn update_rav ( & mut self , allocation_id : Address , rav_value : u128 ) {
@@ -1102,8 +1099,10 @@ pub mod tests {
11021099 ReceiptFees :: RavRequestResponse ( l) ,
11031100 ReceiptFees :: RavRequestResponse ( r) ,
11041101 ) => 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+ }
11071106 _ => false ,
11081107 } ,
11091108 ( ReceiptFees :: Retry , ReceiptFees :: Retry ) => true ,
@@ -1534,14 +1533,14 @@ pub mod tests {
15341533 if let Some ( sender_account) = self . sender_actor . as_ref ( ) {
15351534 sender_account. cast ( SenderAccountMessage :: UpdateReceiptFees (
15361535 * ALLOCATION_ID_0 ,
1537- ReceiptFees :: RavRequestResponse ( Ok ( (
1536+ ReceiptFees :: RavRequestResponse ( (
15381537 UnaggregatedReceipts {
15391538 value : * self . next_unaggregated_fees_value . lock ( ) . unwrap ( ) ,
15401539 last_id : 0 ,
15411540 counter : 0 ,
15421541 } ,
1543- Some ( signed_rav) ,
1544- ) ) ) ,
1542+ Ok ( Some ( signed_rav) ) ,
1543+ ) ) ,
15451544 ) ) ?;
15461545 }
15471546 }
0 commit comments