Skip to content

Commit 24ed493

Browse files
committed
feat: Add backoff to sender
1 parent ee7fb02 commit 24ed493

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tap-agent/src/agent/sender_account.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use super::sender_allocation::{SenderAllocation, SenderAllocationArgs};
3030
use crate::adaptative_concurrency::AdaptiveLimiter;
3131
use crate::agent::sender_allocation::SenderAllocationMessage;
3232
use crate::agent::unaggregated_receipts::UnaggregatedReceipts;
33+
use crate::backoff::BackoffInfo;
3334
use crate::tracker::{SenderFeeTracker, SimpleFeeTracker};
3435
use crate::{
3536
config::{self},
@@ -161,6 +162,9 @@ pub struct State {
161162
config: &'static config::Config,
162163
pgpool: PgPool,
163164
sender_aggregator: jsonrpsee::http_client::HttpClient,
165+
166+
// Backoff info
167+
backoff_info: BackoffInfo,
164168
}
165169

166170
impl State {
@@ -546,6 +550,7 @@ impl Actor for SenderAccount {
546550
retry_interval,
547551
scheduled_rav_request: None,
548552
adaptive_limiter: AdaptiveLimiter::new(INITIAL_RAV_REQUEST_CONCURRENT, 1..50),
553+
backoff_info: BackoffInfo::default(),
549554
};
550555

551556
for allocation_id in &allocation_ids {
@@ -664,17 +669,16 @@ impl Actor for SenderAccount {
664669
counter_greater_receipt_limit,
665670
total_fee_greater_trigger_value,
666671
) {
667-
(true, _) => {
672+
(true, _) if !state.backoff_info.in_backoff() => {
668673
tracing::debug!(
669674
total_counter_for_allocation,
670675
rav_request_receipt_limit = state.config.tap.rav_request_receipt_limit,
671676
%allocation_id,
672677
"Total counter greater than the receipt limit per rav. Triggering RAV request"
673678
);
674-
675679
state.rav_request_for_allocation(allocation_id).await
676680
}
677-
(_, true) => {
681+
(_, true) if !state.backoff_info.in_backoff() => {
678682
tracing::debug!(
679683
total_fee_outside_buffer,
680684
trigger_value = state.config.tap.rav_request_trigger_value,

0 commit comments

Comments
 (0)