@@ -215,6 +215,7 @@ impl State {
215215 . sender_fee_tracker
216216 . get_heaviest_allocation_id ( )
217217 . ok_or_else ( || {
218+ self . backoff_info . fail ( ) ;
218219 anyhow:: anyhow!(
219220 "Error while getting the heaviest allocation, \
220221 this is due one of the following reasons: \n
@@ -225,6 +226,7 @@ impl State {
225226 If this doesn't work, open an issue on our Github."
226227 )
227228 } ) ?;
229+ self . backoff_info . ok ( ) ;
228230 self . rav_request_for_allocation ( allocation_id) . await
229231 }
230232
@@ -655,38 +657,41 @@ impl Actor for SenderAccount {
655657
656658 let has_available_slots_for_requests = state. adaptive_limiter . has_limit ( ) ;
657659 if has_available_slots_for_requests {
658- let total_counter_for_allocation = state
659- . sender_fee_tracker
660- . get_count_outside_buffer_for_allocation ( & allocation_id) ;
661- let can_trigger_rav = state. sender_fee_tracker . can_trigger_rav ( allocation_id) ;
662- let counter_greater_receipt_limit = total_counter_for_allocation
663- >= state. config . tap . rav_request_receipt_limit
664- && can_trigger_rav;
665- let total_fee_outside_buffer = state. sender_fee_tracker . get_ravable_total_fee ( ) ;
666- let total_fee_greater_trigger_value =
667- total_fee_outside_buffer >= state. config . tap . rav_request_trigger_value ;
668- let rav_result = match (
669- counter_greater_receipt_limit,
670- total_fee_greater_trigger_value,
671- ) {
672- ( true , _) if !state. backoff_info . in_backoff ( ) => {
673- tracing:: debug!(
674- total_counter_for_allocation,
675- rav_request_receipt_limit = state. config. tap. rav_request_receipt_limit,
676- %allocation_id,
677- "Total counter greater than the receipt limit per rav. Triggering RAV request"
678- ) ;
679- state. rav_request_for_allocation ( allocation_id) . await
680- }
681- ( _, true ) if !state. backoff_info . in_backoff ( ) => {
682- tracing:: debug!(
683- total_fee_outside_buffer,
684- trigger_value = state. config. tap. rav_request_trigger_value,
685- "Total fee greater than the trigger value. Triggering RAV request"
686- ) ;
660+ let rav_result = if !state. backoff_info . in_backoff ( ) {
661+ let total_fee_outside_buffer =
662+ state. sender_fee_tracker . get_ravable_total_fee ( ) ;
663+ let total_fee_greater_trigger_value =
664+ total_fee_outside_buffer >= state. config . tap . rav_request_trigger_value ;
665+ tracing:: debug!(
666+ total_fee_outside_buffer,
667+ trigger_value = state. config. tap. rav_request_trigger_value,
668+ "Total fee greater than the trigger value. Triggering RAV request"
669+ ) ;
670+ if total_fee_greater_trigger_value {
687671 state. rav_request_for_heaviest_allocation ( ) . await
672+ } else {
673+ Ok ( ( ) )
674+ }
675+ } else {
676+ let total_counter_for_allocation = state
677+ . sender_fee_tracker
678+ . get_count_outside_buffer_for_allocation ( & allocation_id) ;
679+ let can_trigger_rav =
680+ state. sender_fee_tracker . can_trigger_rav ( allocation_id) ;
681+ let counter_greater_receipt_limit = total_counter_for_allocation
682+ >= state. config . tap . rav_request_receipt_limit
683+ && can_trigger_rav;
684+ tracing:: debug!(
685+ total_counter_for_allocation,
686+ rav_request_receipt_limit = state. config. tap. rav_request_receipt_limit,
687+ %allocation_id,
688+ "Total counter greater than the receipt limit per rav. Triggering RAV request"
689+ ) ;
690+ if counter_greater_receipt_limit {
691+ state. rav_request_for_allocation ( allocation_id) . await
692+ } else {
693+ Ok ( ( ) )
688694 }
689- _ => Ok ( ( ) ) ,
690695 } ;
691696 // In case we fail, we want our actor to keep running
692697 if let Err ( err) = rav_result {
0 commit comments