22// SPDX-License-Identifier: Apache-2.0
33
44use std:: collections:: HashSet ;
5+ use std:: sync:: Arc ;
56use std:: time:: Duration ;
67use std:: { collections:: HashMap , str:: FromStr } ;
78
@@ -12,6 +13,7 @@ use alloy::primitives::Address;
1213use anyhow:: Result ;
1314use anyhow:: { anyhow, bail} ;
1415use eventuals:: { Eventual , EventualExt , PipeHandle } ;
16+ use futures:: { stream, StreamExt } ;
1517use indexer_common:: escrow_accounts:: EscrowAccounts ;
1618use indexer_common:: prelude:: { Allocation , SubgraphClient } ;
1719use ractor:: { Actor , ActorCell , ActorProcessingErr , ActorRef , SupervisionEvent } ;
@@ -160,12 +162,15 @@ impl Actor for SenderAccountsManager {
160162 }
161163 } ;
162164
163- for ( sender_id, allocation_ids) in sender_allocation {
164- state. sender_ids . insert ( sender_id) ;
165- state
166- . create_or_deny_sender ( myself. get_cell ( ) , sender_id, allocation_ids)
167- . await ;
168- }
165+ state. sender_ids . extend ( sender_allocation. keys ( ) ) ;
166+
167+ stream:: iter ( sender_allocation)
168+ . map ( |( sender_id, allocation_ids) | {
169+ state. create_or_deny_sender ( myself. get_cell ( ) , sender_id, allocation_ids)
170+ } )
171+ . buffered ( 10 ) // Limit concurrency to 10 senders at a time
172+ . collect :: < Vec < ( ) > > ( )
173+ . await ;
169174
170175 // Start the new_receipts_watcher task that will consume from the `pglistener`
171176 // after starting all senders
0 commit comments