From 99740aab56ffa9f241136e7781625ae4e3d1e5ea Mon Sep 17 00:00:00 2001 From: taslimmuhammed Date: Sun, 27 Oct 2024 06:22:24 +0530 Subject: [PATCH] initial accounts --- common/src/escrow_accounts.rs | 11 ++++++++--- common/src/indexer_service/http/indexer_service.rs | 3 ++- tap-agent/src/agent.rs | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/src/escrow_accounts.rs b/common/src/escrow_accounts.rs index 6a5485dd..fcfdaaa8 100644 --- a/common/src/escrow_accounts.rs +++ b/common/src/escrow_accounts.rs @@ -101,13 +101,17 @@ type BigInt = String; )] pub struct EscrowAccountQuery; -pub fn escrow_accounts( +pub async fn escrow_accounts( escrow_subgraph: &'static SubgraphClient, indexer_address: Address, interval: Duration, reject_thawing_signers: bool, ) -> Receiver { - let (tx, rx) = watch::channel(EscrowAccounts::default()); + let initial_accounts = + get_escrow_accounts(escrow_subgraph, indexer_address, reject_thawing_signers) + .await + .expect("Failed to create escrow_accounts channel"); + let (tx, rx) = watch::channel(initial_accounts); tokio::spawn(async move { let mut time_interval = time::interval(interval); time_interval.set_missed_tick_behavior(time::MissedTickBehavior::Skip); @@ -251,7 +255,8 @@ mod tests { *test_vectors::INDEXER_ADDRESS, Duration::from_secs(60), true, - ); + ) + .await; accounts.changed().await.unwrap(); assert_eq!( accounts.borrow().clone(), diff --git a/common/src/indexer_service/http/indexer_service.rs b/common/src/indexer_service/http/indexer_service.rs index 7484d9e6..c8a6b908 100644 --- a/common/src/indexer_service/http/indexer_service.rs +++ b/common/src/indexer_service/http/indexer_service.rs @@ -276,7 +276,8 @@ impl IndexerService { options.config.indexer.indexer_address, Duration::from_secs(options.config.escrow_subgraph.syncing_interval), true, // Reject thawing signers eagerly - ); + ) + .await; // Establish Database connection necessary for serving indexer management // requests with defined schema diff --git a/tap-agent/src/agent.rs b/tap-agent/src/agent.rs index 038cf5f5..763428d9 100644 --- a/tap-agent/src/agent.rs +++ b/tap-agent/src/agent.rs @@ -118,7 +118,8 @@ pub async fn start_agent() -> (ActorRef, JoinHandl *indexer_address, *escrow_sync_interval, false, - ); + ) + .await; let config = Box::leak(Box::new(SenderAccountConfig::from_config(&CONFIG)));