Skip to content

Commit ca55cea

Browse files
committed
Make RAV value threshold per sender
Fixes #93 Signed-off-by: Alexis Asseman <[email protected]>
1 parent 6a0eed3 commit ca55cea

10 files changed

+1693
-1211
lines changed

tap-agent/src/agent.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ use indexer_common::prelude::{
99
};
1010

1111
use crate::{
12-
aggregator_endpoints, config, database,
13-
tap::sender_allocation_relationships_manager::SenderAllocationRelationshipsManager,
12+
aggregator_endpoints, config, database, tap::sender_accounts_manager::SenderAccountsManager,
1413
};
1514

16-
pub async fn start_agent(config: &'static config::Cli) -> SenderAllocationRelationshipsManager {
15+
pub async fn start_agent(config: &'static config::Cli) -> SenderAccountsManager {
1716
let pgpool = database::connect(&config.postgres).await;
1817

1918
let http_client = reqwest::Client::new();
@@ -80,7 +79,7 @@ pub async fn start_agent(config: &'static config::Cli) -> SenderAllocationRelati
8079
verifying_contract: config.receipts.receipts_verifier_address,
8180
};
8281

83-
SenderAllocationRelationshipsManager::new(
82+
SenderAccountsManager::new(
8483
config,
8584
pgpool,
8685
indexer_allocations,

tap-agent/src/tap/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ mod escrow_adapter;
1010
mod rav_storage_adapter;
1111
mod receipt_checks_adapter;
1212
mod receipt_storage_adapter;
13-
mod sender_allocation_relationship;
14-
pub mod sender_allocation_relationships_manager;
13+
mod sender_account;
14+
pub mod sender_accounts_manager;
15+
mod sender_allocation;
16+
mod unaggregated_receipts;
1517

1618
#[cfg(test)]
1719
pub mod test_utils;

tap-agent/src/tap/rav_storage_adapter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ impl RAVStorageAdapter {
9696
#[cfg(test)]
9797
mod test {
9898
use super::*;
99-
use crate::tap::test_utils::{create_rav, ALLOCATION_ID, SENDER, SIGNER};
99+
use crate::tap::test_utils::{create_rav, ALLOCATION_ID_0, SENDER, SIGNER};
100100
use tap_core::adapters::rav_storage_adapter::RAVStorageAdapter as RAVStorageAdapterTrait;
101101

102102
#[sqlx::test(migrations = "../migrations")]
103103
async fn update_and_retrieve_rav(pool: PgPool) {
104104
let timestamp_ns = u64::MAX - 10;
105105
let value_aggregate = u128::MAX;
106-
let rav_storage_adapter = RAVStorageAdapter::new(pool.clone(), *ALLOCATION_ID, SENDER.1);
106+
let rav_storage_adapter = RAVStorageAdapter::new(pool.clone(), *ALLOCATION_ID_0, SENDER.1);
107107

108108
// Insert a rav
109109
let mut new_rav = create_rav(
110-
*ALLOCATION_ID,
110+
*ALLOCATION_ID_0,
111111
SIGNER.0.clone(),
112112
timestamp_ns,
113113
value_aggregate,
@@ -126,7 +126,7 @@ mod test {
126126
// Update the RAV 3 times in quick succession
127127
for i in 0..3 {
128128
new_rav = create_rav(
129-
*ALLOCATION_ID,
129+
*ALLOCATION_ID_0,
130130
SIGNER.0.clone(),
131131
timestamp_ns + i,
132132
value_aggregate - (i as u128),

tap-agent/src/tap/receipt_storage_adapter.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ mod test {
199199

200200
use super::*;
201201
use crate::tap::test_utils::{
202-
create_received_receipt, store_receipt, ALLOCATION_ID, ALLOCATION_ID_IRRELEVANT, SENDER,
202+
create_received_receipt, store_receipt, ALLOCATION_ID_0, ALLOCATION_ID_IRRELEVANT, SENDER,
203203
SENDER_IRRELEVANT, SIGNER, TAP_EIP712_DOMAIN_SEPARATOR,
204204
};
205205
use anyhow::Result;
@@ -386,7 +386,7 @@ mod test {
386386

387387
let storage_adapter = ReceiptStorageAdapter::new(
388388
pgpool.clone(),
389-
*ALLOCATION_ID,
389+
*ALLOCATION_ID_0,
390390
SENDER.1,
391391
get_full_list_of_checks(),
392392
escrow_accounts.clone(),
@@ -397,7 +397,7 @@ mod test {
397397
for i in 0..10 {
398398
received_receipt_vec.push(
399399
create_received_receipt(
400-
&ALLOCATION_ID,
400+
&ALLOCATION_ID_0,
401401
&SIGNER.0,
402402
i + 684,
403403
i + 42,
@@ -421,7 +421,7 @@ mod test {
421421
);
422422
received_receipt_vec.push(
423423
create_received_receipt(
424-
&ALLOCATION_ID,
424+
&ALLOCATION_ID_0,
425425
&SENDER_IRRELEVANT.0,
426426
i + 684,
427427
i + 42,
@@ -530,7 +530,7 @@ mod test {
530530

531531
let storage_adapter = ReceiptStorageAdapter::new(
532532
pgpool,
533-
*ALLOCATION_ID,
533+
*ALLOCATION_ID_0,
534534
SENDER.1,
535535
get_full_list_of_checks(),
536536
escrow_accounts.clone(),
@@ -541,7 +541,7 @@ mod test {
541541
for i in 0..10 {
542542
received_receipt_vec.push(
543543
create_received_receipt(
544-
&ALLOCATION_ID,
544+
&ALLOCATION_ID_0,
545545
&SIGNER.0,
546546
i + 684,
547547
i + 42,
@@ -565,7 +565,7 @@ mod test {
565565
);
566566
received_receipt_vec.push(
567567
create_received_receipt(
568-
&ALLOCATION_ID,
568+
&ALLOCATION_ID_0,
569569
&SENDER_IRRELEVANT.0,
570570
i + 684,
571571
i + 42,

0 commit comments

Comments
 (0)