@@ -4,6 +4,7 @@ use near_jsonrpc_primitives::types::query::QueryResponseKind;
44use near_primitives:: hash:: CryptoHash ;
55use near_primitives:: types:: { BlockReference , Nonce } ;
66use std:: { collections:: HashMap , sync:: Arc } ;
7+ use tokio:: sync:: Mutex ;
78
89use tracing:: { error, info, warn} ;
910
@@ -148,21 +149,16 @@ impl Engine {
148149 . or_default ( )
149150 . extend ( default_transactions) ;
150151 }
152+ let run_account_transactions_once_mutex = Arc :: new ( Mutex :: new ( ( ) ) ) ;
151153
152154 // Spawn a task for each interval group
153- for ( task_id, ( interval_duration, transaction_kinds) ) in
154- interval_groups. into_iter ( ) . enumerate ( )
155- {
155+ for ( interval_duration, transaction_kinds) in interval_groups. into_iter ( ) {
156156 let opts_clone = opts. clone ( ) ;
157157 let metrics_clone = metrics. clone ( ) ;
158158 let transactions_clone = transactions. clone ( ) ;
159159
160+ let mutex_clone = Arc :: clone ( & run_account_transactions_once_mutex) ;
160161 tasks. spawn ( async move {
161- // Add 3 second delay between each interval group start
162- if task_id > 0 {
163- tokio:: time:: sleep ( group_delay) . await ;
164- }
165-
166162 let mut interval = interval ( interval_duration) ;
167163 loop {
168164 interval. tick ( ) . await ;
@@ -181,6 +177,8 @@ impl Engine {
181177 . map ( |( kind, tx) | ( kind. clone ( ) , tx. clone ( ) ) )
182178 . collect ( ) ;
183179
180+ let _lock = mutex_clone. lock ( ) . await ;
181+
184182 run_account_transactions_once (
185183 filtered_transactions,
186184 opts_clone. clone ( ) ,
0 commit comments