Skip to content

Commit fee3baa

Browse files
taslimmuhammedgusinacio
authored andcommitted
optimise
1 parent 6d25ea3 commit fee3baa

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

tap-agent/src/agent/sender_account.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,13 @@ impl Actor for SenderAccount {
500500
let _indexer_allocations_handle = watch_pipe(indexer_allocations, move |allocation_ids| {
501501
let myself = myself_clone.clone();
502502
let allocation_ids = allocation_ids.clone();
503-
async move {
504-
// Update the allocation_ids
505-
myself
506-
.cast(SenderAccountMessage::UpdateAllocationIds(allocation_ids))
507-
.unwrap_or_else(|e| {
508-
error!("Error while updating allocation_ids: {:?}", e);
509-
});
510-
}
503+
// Update the allocation_ids
504+
myself
505+
.cast(SenderAccountMessage::UpdateAllocationIds(allocation_ids))
506+
.unwrap_or_else(|e| {
507+
error!("Error while updating allocation_ids: {:?}", e);
508+
});
509+
async {}
511510
});
512511

513512
let myself_clone = myself.clone();
@@ -516,13 +515,12 @@ impl Actor for SenderAccount {
516515
let _escrow_account_monitor = watch_pipe(accounts_clone, move |escrow_account| {
517516
let myself = myself_clone.clone();
518517
let pgpool = pgpool_clone.clone();
519-
let escrow_account = escrow_account.clone();
518+
// Get balance or default value for sender
519+
// this balance already takes into account thawing
520+
let balance = escrow_account
521+
.get_balance_for_sender(&sender_id)
522+
.unwrap_or_default();
520523
async move {
521-
// Get balance or default value for sender
522-
// this balance already takes into account thawing
523-
let balance = escrow_account
524-
.get_balance_for_sender(&sender_id)
525-
.unwrap_or_default();
526524
let last_non_final_ravs = sqlx::query!(
527525
r#"
528526
SELECT allocation_id, value_aggregate

tap-agent/src/agent/sender_accounts_manager.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ impl Actor for SenderAccountsManager {
108108
watch_pipe(indexer_allocations.clone(), move |allocation_id| {
109109
let allocations_tx = allocations_tx.clone();
110110
let allocation_set = allocation_id.keys().cloned().collect::<HashSet<Address>>();
111-
async move {
112-
allocations_tx
113-
.send(allocation_set)
114-
.expect("Failed to update indexer_allocations_set channel");
115-
}
111+
allocations_tx
112+
.send(allocation_set)
113+
.expect("Failed to update indexer_allocations_set channel");
114+
async {}
116115
});
117116
let mut pglistener = PgListener::connect_with(&pgpool.clone()).await.unwrap();
118117
pglistener
@@ -128,13 +127,12 @@ impl Actor for SenderAccountsManager {
128127
watch_pipe(accounts_clone, move |escrow_accounts| {
129128
let myself = myself_clone.clone();
130129
let senders = escrow_accounts.get_senders();
131-
async move {
132-
myself
133-
.cast(SenderAccountsManagerMessage::UpdateSenderAccounts(senders))
134-
.unwrap_or_else(|e| {
135-
error!("Error while updating sender_accounts: {:?}", e);
136-
});
137-
}
130+
myself
131+
.cast(SenderAccountsManagerMessage::UpdateSenderAccounts(senders))
132+
.unwrap_or_else(|e| {
133+
error!("Error while updating sender_accounts: {:?}", e);
134+
});
135+
async {}
138136
});
139137

140138
let mut state = State {

0 commit comments

Comments
 (0)