From ba0c552af914ca3261b06845249291b7f9506777 Mon Sep 17 00:00:00 2001 From: Carlos V Date: Thu, 2 May 2024 19:17:34 +0000 Subject: [PATCH 1/2] feat: Add receipt limit --- tap-agent/src/agent/sender_allocation.rs | 4 ++-- tap-agent/src/config.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tap-agent/src/agent/sender_allocation.rs b/tap-agent/src/agent/sender_allocation.rs index c06b23a3..a1ebbe81 100644 --- a/tap-agent/src/agent/sender_allocation.rs +++ b/tap-agent/src/agent/sender_allocation.rs @@ -334,8 +334,7 @@ impl SenderAllocationState { .tap_manager .create_rav_request( self.config.tap.rav_request_timestamp_buffer_ms * 1_000_000, - // TODO: limit the number of receipts to aggregate per request. - None, + Some(self.config.tap.rav_request_receipt_limit), ) .await .map_err(|e| match e { @@ -628,6 +627,7 @@ mod tests { rav_request_trigger_value: 100, rav_request_timestamp_buffer_ms: 1, rav_request_timeout_secs: 5, + rav_request_receipt_limit: 1000, ..Default::default() }, ..Default::default() diff --git a/tap-agent/src/config.rs b/tap-agent/src/config.rs index fbf74ce5..cf90d23e 100644 --- a/tap-agent/src/config.rs +++ b/tap-agent/src/config.rs @@ -239,7 +239,7 @@ pub struct Tap { env = "RAV_REQUEST_TIMESTAMP_BUFFER", help = "Buffer (in ms) to add between the current time and the timestamp of the \ last unaggregated fee when triggering a RAV request.", - default_value_t = 1_000 // 1 second + default_value_t = 60_000 // 60 seconds )] pub rav_request_timestamp_buffer_ms: u64, #[clap( @@ -259,6 +259,15 @@ pub struct Tap { help = "YAML file with a map of sender addresses to aggregator endpoints." )] pub sender_aggregator_endpoints_file: PathBuf, + + #[clap( + long, + value_name = "rav-request-receipt-limit", + env = "RAV_REQUEST_RECEIPT_LIMIT", + help = "Amount that will define the limit of receipts to aggregate per request", + default_value_t = 10000 + )] + pub rav_request_receipt_limit: u64, } /// Sets up tracing, allows log level to be set from the environment variables From c50367ba240929618b82d075ee209de1c2b50878 Mon Sep 17 00:00:00 2001 From: Carlos V Date: Thu, 2 May 2024 21:31:53 +0000 Subject: [PATCH 2/2] fix: Give more accurate help for rav_request_receipt_limit --- tap-agent/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tap-agent/src/config.rs b/tap-agent/src/config.rs index cf90d23e..1718ef12 100644 --- a/tap-agent/src/config.rs +++ b/tap-agent/src/config.rs @@ -264,7 +264,7 @@ pub struct Tap { long, value_name = "rav-request-receipt-limit", env = "RAV_REQUEST_RECEIPT_LIMIT", - help = "Amount that will define the limit of receipts to aggregate per request", + help = "Maximum number of receipts per aggregation request", default_value_t = 10000 )] pub rav_request_receipt_limit: u64,