diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 584fb045f..1dda75c21 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -37,6 +37,20 @@ const MAX_TX_QUEUE_AGE: u64 = (MAX_PROCESSING_AGE as f64 * DEFAULT_S_PER_SLOT) a pub type SharedTransactions = Arc>>>; +/// Split input vector of keypairs into two sets of chunks of given size +fn split_into_source_destination( + keypairs: &[Keypair], + chunk_size: usize, +) -> (Vec>, Vec>) { + let mut source_keypair_chunks: Vec> = Vec::new(); + let mut dest_keypair_chunks: Vec> = Vec::new(); + for chunk in keypairs.chunks_exact(2 * chunk_size) { + source_keypair_chunks.push(chunk[..chunk_size].iter().collect()); + dest_keypair_chunks.push(chunk[chunk_size..].iter().collect()); + } + (source_keypair_chunks, dest_keypair_chunks) +} + fn wait_for_target_slots_per_epoch(target_slots_per_epoch: u64, client: &Arc) where T: 'static + BenchTpsClient + Send + Sync, @@ -201,13 +215,9 @@ where .. } = config; - let mut source_keypair_chunks: Vec> = Vec::new(); - let mut dest_keypair_chunks: Vec> = Vec::new(); assert!(gen_keypairs.len() >= 2 * tx_count); - for chunk in gen_keypairs.chunks_exact(2 * tx_count) { - source_keypair_chunks.push(chunk[..tx_count].iter().collect()); - dest_keypair_chunks.push(chunk[tx_count..].iter().collect()); - } + let (source_keypair_chunks, mut dest_keypair_chunks) = + split_into_source_destination(&gen_keypairs, tx_count); let first_tx_count = loop { match client.get_transaction_count() {