@@ -179,7 +179,7 @@ impl Actor for SenderAllocation {
179
179
}
180
180
181
181
// update unaggregated_fees
182
- state. unaggregated_fees = state. initialize_unaggregated_receipts ( ) . await ?;
182
+ state. unaggregated_fees = state. recalculate_all_unaggregated_fees ( ) . await ?;
183
183
184
184
sender_account_ref. cast ( SenderAccountMessage :: UpdateReceiptFees (
185
185
allocation_id,
@@ -212,6 +212,20 @@ impl Actor for SenderAllocation {
212
212
allocation_id = %state. allocation_id,
213
213
"Closing SenderAllocation, triggering last rav" ,
214
214
) ;
215
+ loop {
216
+ match state. recalculate_all_unaggregated_fees ( ) . await {
217
+ Ok ( value) => {
218
+ state. unaggregated_fees = value;
219
+ break ;
220
+ }
221
+ Err ( err) => {
222
+ error ! (
223
+ error = %err,
224
+ "There was an error while calculating the last unaggregated receipts. Retrying in 30 seconds..." ) ;
225
+ tokio:: time:: sleep ( Duration :: from_secs ( 30 ) ) . await ;
226
+ }
227
+ }
228
+ }
215
229
// Request a RAV and mark the allocation as final.
216
230
while state. unaggregated_fees . value > 0 {
217
231
if let Err ( err) = state. request_rav ( ) . await {
@@ -380,7 +394,7 @@ impl SenderAllocationState {
380
394
} )
381
395
}
382
396
383
- async fn initialize_unaggregated_receipts ( & self ) -> Result < UnaggregatedReceipts > {
397
+ async fn recalculate_all_unaggregated_fees ( & self ) -> Result < UnaggregatedReceipts > {
384
398
self . calculate_fee_until_last_id ( i64:: MAX ) . await
385
399
}
386
400
@@ -1412,7 +1426,7 @@ pub mod tests {
1412
1426
}
1413
1427
1414
1428
// calculate unaggregated fee
1415
- let total_unaggregated_fees = state. initialize_unaggregated_receipts ( ) . await . unwrap ( ) ;
1429
+ let total_unaggregated_fees = state. recalculate_all_unaggregated_fees ( ) . await . unwrap ( ) ;
1416
1430
1417
1431
// Check that the unaggregated fees are correct.
1418
1432
assert_eq ! ( total_unaggregated_fees. value, 45u128 ) ;
@@ -1467,7 +1481,7 @@ pub mod tests {
1467
1481
. unwrap ( ) ;
1468
1482
}
1469
1483
1470
- let total_unaggregated_fees = state. initialize_unaggregated_receipts ( ) . await . unwrap ( ) ;
1484
+ let total_unaggregated_fees = state. recalculate_all_unaggregated_fees ( ) . await . unwrap ( ) ;
1471
1485
1472
1486
// Check that the unaggregated fees are correct.
1473
1487
assert_eq ! ( total_unaggregated_fees. value, 35u128 ) ;
0 commit comments