Skip to content

Commit

Permalink
fix: duration conversions
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Nov 13, 2023
1 parent 446bde2 commit 8e6460f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tap-agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn start_agent(config: &'static config::Cli) {
network_subgraph,
config.ethereum.indexer_address,
1,
Duration::from_secs(config.network_subgraph.allocation_syncing_interval),
Duration::from_millis(config.network_subgraph.allocation_syncing_interval_ms),
);

let escrow_subgraph = Box::leak(Box::new(SubgraphClient::new(
Expand All @@ -64,7 +64,7 @@ pub async fn start_agent(config: &'static config::Cli) {
let escrow_accounts = escrow_accounts(
escrow_subgraph,
config.ethereum.indexer_address,
Duration::from_secs(config.escrow_subgraph.escrow_syncing_interval),
Duration::from_millis(config.escrow_subgraph.escrow_syncing_interval_ms),
);

// TODO: replace with a proper implementation once the gateway registry contract is ready
Expand Down
10 changes: 5 additions & 5 deletions tap-agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub struct NetworkSubgraph {
default_value_t = 120_000,
help = "Interval (in ms) for syncing indexer allocations from the network"
)]
pub allocation_syncing_interval: u64,
pub allocation_syncing_interval_ms: u64,
}

#[derive(Clone, Debug, Args, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -208,7 +208,7 @@ pub struct EscrowSubgraph {
default_value_t = 120_000,
help = "Interval (in ms) for syncing indexer escrow accounts from the escrow subgraph"
)]
pub escrow_syncing_interval: u64,
pub escrow_syncing_interval_ms: u64,
}

#[derive(Clone, Debug, Args, Serialize, Deserialize, Default)]
Expand All @@ -226,11 +226,11 @@ pub struct Tap {
long,
value_name = "rav-request-timestamp-buffer",
env = "RAV_REQUEST_TIMESTAMP_BUFFER",
help = "Buffer (in ns) to add between the current time and the timestamp of the \
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_000_000 // 1 second
default_value_t = 1_000 // 1 second
)]
pub rav_request_timestamp_buffer_ns: u64,
pub rav_request_timestamp_buffer_ms: u64,
#[clap(
long,
value_name = "rav-request-timeout",
Expand Down
8 changes: 4 additions & 4 deletions tap-agent/src/tap/receipt_checks_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ReceiptChecksAdapter {
sender_id,
config.ethereum.indexer_address,
escrow_subgraph,
config.escrow_subgraph.escrow_syncing_interval,
config.escrow_subgraph.escrow_syncing_interval_ms,
);
Self {
query_appraisals,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl ReceiptChecksAdapter {
sender_address: Address,
indexer_address: Address,
escrow_subgraph: &'static SubgraphClient,
escrow_subgraph_polling_interval: u64,
escrow_subgraph_polling_interval_ms: u64,
) -> Eventual<bool> {
#[derive(serde::Deserialize)]
struct AllocationResponse {
Expand All @@ -150,7 +150,7 @@ impl ReceiptChecksAdapter {
transactions: Vec<AllocationResponse>,
}

timer(Duration::from_secs(escrow_subgraph_polling_interval)).map_with_retry(
timer(Duration::from_millis(escrow_subgraph_polling_interval_ms)).map_with_retry(
move |_| async move {
let response = escrow_subgraph
.query::<TransactionsResponse>(&json!({
Expand Down Expand Up @@ -198,7 +198,7 @@ impl ReceiptChecksAdapter {
"Failed to check the escrow redeem status for allocation {} and sender {}: {}",
allocation_id, sender_address, error
);
sleep(Duration::from_secs(escrow_subgraph_polling_interval).div_f32(2.))
sleep(Duration::from_millis(escrow_subgraph_polling_interval_ms).div_f32(2.))
},
)
}
Expand Down
4 changes: 2 additions & 2 deletions tap-agent/src/tap/sender_allocation_relationship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl SenderAllocationRelationship {
expected_rav,
} = inner
.tap_manager
.create_rav_request(inner.config.tap.rav_request_timestamp_buffer_ns)
.create_rav_request(inner.config.tap.rav_request_timestamp_buffer_ms * 1_000_000)
.await?;

// TODO: Request compression and response decompression. Also a fancy user agent?
Expand Down Expand Up @@ -441,7 +441,7 @@ mod tests {
},
tap: config::Tap {
rav_request_trigger_value: 100,
rav_request_timestamp_buffer_ns: 1000,
rav_request_timestamp_buffer_ms: 1,
rav_request_timeout_secs: 5,
..Default::default()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ mod tests {
},
tap: config::Tap {
rav_request_trigger_value: 100,
rav_request_timestamp_buffer_ns: 1000,
rav_request_timestamp_buffer_ms: 1,
..Default::default()
},
..Default::default()
Expand Down

0 comments on commit 8e6460f

Please sign in to comment.