Skip to content

Commit c9493b9

Browse files
authored
Variable group_delay (#10)
this is required because mainnet and testnet are moving at different rates and there are still nonce conflicts
2 parents 7ffbeb5 + f4910c3 commit c9493b9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ pub struct Opts {
6464
/// Time difference between benchmarking runs
6565
#[clap(env, short, long, value_parser = humantime::parse_duration, default_value = "15m")]
6666
pub period: std::time::Duration,
67+
/// Time delay between each intervalgroup of transactions
68+
#[clap(env, short, long, value_parser = humantime::parse_duration, default_value = "5s")]
69+
pub group_delay: std::time::Duration,
6770
/// Override intervals for specific transaction types (JSON format: {"MpcSign": "5m", "Swap": "10m"})
6871
#[clap(env, long, value_parser = parse_interval_overwrite)]
6972
pub interval_overwrite: Option<HashMap<TransactionKind, std::time::Duration>>,

src/transaction/engine.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ impl Engine {
114114
// Clone necessary data before borrowing
115115
let transactions = self.transactions.clone();
116116
let default_interval = opts.period;
117+
let group_delay = opts.group_delay;
118+
info!("group delay: {:?}", group_delay);
117119

118120
// Group transactions by their intervals
119121
let mut interval_groups: HashMap<std::time::Duration, Vec<TransactionKind>> =
@@ -152,7 +154,7 @@ impl Engine {
152154
tasks.spawn(async move {
153155
// Add 3 second delay between each interval group start
154156
if task_id > 0 {
155-
tokio::time::sleep(tokio::time::Duration::from_secs(3 * task_id as u64)).await;
157+
tokio::time::sleep(group_delay).await;
156158
}
157159

158160
let mut interval = interval(interval_duration);
@@ -438,6 +440,7 @@ mod tests {
438440
pool_id: 0,
439441
transaction_kind: vec![],
440442
period: Duration::from_millis(1),
443+
group_delay: Duration::from_secs(3),
441444
interval_overwrite: None,
442445
metric_server_address: SocketAddr::from_str("0.0.0.0:9000").unwrap(),
443446
location: LOCATION.to_string(),

0 commit comments

Comments
 (0)