@@ -209,6 +209,7 @@ impl State {
209209 . sender_fee_tracker
210210 . get_heaviest_allocation_id ( )
211211 . ok_or_else ( || {
212+ self . backoff_info . fail ( ) ;
212213 anyhow:: anyhow!(
213214 "Error while getting the heaviest allocation, \
214215 this is due one of the following reasons: \n
@@ -219,6 +220,7 @@ impl State {
219220 If this doesn't work, open an issue on our Github."
220221 )
221222 } ) ?;
223+ self . backoff_info . ok ( ) ;
222224 self . rav_request_for_allocation ( allocation_id) . await
223225 }
224226
@@ -642,48 +644,47 @@ impl Actor for SenderAccount {
642644 if should_deny {
643645 state. add_to_denylist ( ) . await ;
644646 }
645- let total_counter_for_allocation = state
646- . sender_fee_tracker
647- . get_count_outside_buffer_for_allocation ( & allocation_id) ;
648- let can_trigger_rav = state. sender_fee_tracker . can_trigger_rav ( allocation_id) ;
649- let counter_greater_receipt_limit = total_counter_for_allocation
650- >= state. config . tap . rav_request_receipt_limit
651- && can_trigger_rav;
652- let total_fee_outside_buffer = state. sender_fee_tracker . get_ravable_total_fee ( ) ;
653- let total_fee_greater_trigger_value =
654- total_fee_outside_buffer >= state. config . tap . rav_request_trigger_value ;
655- let rav_result = match (
656- counter_greater_receipt_limit,
657- total_fee_greater_trigger_value,
658- ) {
659- ( true , _) if !state. backoff_info . in_backoff ( ) => {
660- tracing:: debug!(
661- total_counter_for_allocation,
662- rav_request_receipt_limit = state. config. tap. rav_request_receipt_limit,
663- %allocation_id,
664- "Total counter greater than the receipt limit per rav. Triggering RAV request"
665- ) ;
666- state. rav_request_for_allocation ( allocation_id) . await
667- }
668- ( _, true ) if !state. backoff_info . in_backoff ( ) => {
669- tracing:: debug!(
670- total_fee_outside_buffer,
671- trigger_value = state. config. tap. rav_request_trigger_value,
672- "Total fee greater than the trigger value. Triggering RAV request"
673- ) ;
647+ let rav_result = if !state. backoff_info . in_backoff ( ) {
648+ let total_fee_outside_buffer = state. sender_fee_tracker . get_ravable_total_fee ( ) ;
649+ let total_fee_greater_trigger_value =
650+ total_fee_outside_buffer >= state. config . tap . rav_request_trigger_value ;
651+ tracing:: debug!(
652+ total_fee_outside_buffer,
653+ trigger_value = state. config. tap. rav_request_trigger_value,
654+ "Total fee greater than the trigger value. Triggering RAV request"
655+ ) ;
656+ if total_fee_greater_trigger_value {
674657 state. rav_request_for_heaviest_allocation ( ) . await
658+ } else {
659+ Ok ( ( ) )
660+ }
661+ } else {
662+ let total_counter_for_allocation = state
663+ . sender_fee_tracker
664+ . get_count_outside_buffer_for_allocation ( & allocation_id) ;
665+ let can_trigger_rav = state. sender_fee_tracker . can_trigger_rav ( allocation_id) ;
666+ let counter_greater_receipt_limit = total_counter_for_allocation
667+ >= state. config . tap . rav_request_receipt_limit
668+ && can_trigger_rav;
669+ tracing:: debug!(
670+ total_counter_for_allocation,
671+ rav_request_receipt_limit = state. config. tap. rav_request_receipt_limit,
672+ %allocation_id,
673+ "Total counter greater than the receipt limit per rav. Triggering RAV request"
674+ ) ;
675+ if counter_greater_receipt_limit {
676+ state. rav_request_for_allocation ( allocation_id) . await
677+ } else {
678+ Ok ( ( ) )
675679 }
676- _ => Ok ( ( ) ) ,
677680 } ;
681+
678682 // In case we fail, we want our actor to keep running
679683 if let Err ( err) = rav_result {
680- state. backoff_info . fail ( ) ;
681684 tracing:: error!(
682685 error = %err,
683686 "There was an error while requesting a RAV."
684687 ) ;
685- } else {
686- state. backoff_info . ok ( ) ;
687688 }
688689
689690 match ( state. denied , state. deny_condition_reached ( ) ) {
0 commit comments