Skip to content

Commit

Permalink
refactor: rename EscrowAccount's balances to sender_balances
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Jan 15, 2024
1 parent f8bca98 commit 229b792
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions common/src/escrow_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use crate::prelude::{Query, SubgraphClient};

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct EscrowAccounts {
pub balances: HashMap<Address, U256>,
pub senders_balances: HashMap<Address, U256>,
pub signers_to_senders: HashMap<Address, Address>,
pub senders_to_signers: HashMap<Address, Vec<Address>>,
}

impl EscrowAccounts {
pub fn new(
balances: HashMap<Address, U256>,
senders_balances: HashMap<Address, U256>,
senders_to_signers: HashMap<Address, Vec<Address>>,
) -> Self {
let signers_to_senders = senders_to_signers
Expand All @@ -36,7 +36,7 @@ impl EscrowAccounts {
.collect();

Self {
balances,
senders_balances,
signers_to_senders,
senders_to_signers,
}
Expand Down Expand Up @@ -133,7 +133,7 @@ pub fn escrow_accounts(

let response = response.map_err(|e| e.to_string())?;

let balances = response
let senders_balances = response
.escrow_accounts
.iter()
.map(|account| {
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn escrow_accounts(
})
.collect();

Ok(EscrowAccounts::new(balances, senders_to_signers))
Ok(EscrowAccounts::new(senders_balances, senders_to_signers))
},
move |err: String| {
error!(
Expand Down
2 changes: 1 addition & 1 deletion common/src/tap_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl TapManager {
})?;

if !escrow_accounts
.balances
.senders_balances
.get(receipt_sender)
.map_or(false, |balance| balance > &U256::zero())
{
Expand Down
2 changes: 1 addition & 1 deletion tap-agent/src/tap/escrow_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl EscrowAdapterTrait for EscrowAdapter {
})?;

let balance = escrow_accounts
.balances
.senders_balances
.get(sender)
.ok_or(AdapterError::AdapterError {
error: format!(
Expand Down
2 changes: 1 addition & 1 deletion tap-agent/src/tap/receipt_checks_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl ReceiptChecksAdapterTrait for ReceiptChecksAdapter {
Ok(escrow_accounts
.signers_to_senders
.get(&sender_id)
.and_then(|sender| escrow_accounts.balances.get(sender))
.and_then(|sender| escrow_accounts.senders_balances.get(sender))
.map(|balance| *balance > U256::from(0))
.unwrap_or(false))
}
Expand Down
8 changes: 6 additions & 2 deletions tap-agent/src/tap/sender_allocation_relationships_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ impl SenderAllocationRelationshipsManager {
.value()
.await
.expect("Should get indexer allocations from Eventual"),
escrow_accounts_snapshot.balances.keys().copied().collect(),
escrow_accounts_snapshot
.senders_balances
.keys()
.copied()
.collect(),
)
.await
.expect("Should be able to update sender_allocation_relationships");
Expand Down Expand Up @@ -186,7 +190,7 @@ impl SenderAllocationRelationshipsManager {
Self::update_sender_allocation_relationships(
&inner,
indexer_allocations,
escrow_accounts.balances.keys().copied().collect(),
escrow_accounts.senders_balances.keys().copied().collect(),
)
.await
.unwrap_or_else(|e| {
Expand Down

0 comments on commit 229b792

Please sign in to comment.