From b889208f27f2d6df591f189bd6ea299c6b0f8ab4 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Fri, 8 Apr 2022 16:54:35 -0500 Subject: [PATCH] add option to send transfer to same account --- banking-bench/src/main.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/banking-bench/src/main.rs b/banking-bench/src/main.rs index 2231a0423b3952..cf716da89c1225 100644 --- a/banking-bench/src/main.rs +++ b/banking-bench/src/main.rs @@ -70,6 +70,7 @@ fn make_accounts_txs( total_num_transactions: usize, hash: Hash, same_payer: bool, + same_write_account: bool, ) -> Vec { let to_pubkey = solana_sdk::pubkey::new_rand(); let payer_key = Keypair::new(); @@ -82,7 +83,9 @@ fn make_accounts_txs( if !same_payer { new.message.account_keys[0] = solana_sdk::pubkey::new_rand(); } - new.message.account_keys[1] = solana_sdk::pubkey::new_rand(); + if !same_write_account { + new.message.account_keys[1] = solana_sdk::pubkey::new_rand(); + } new.signatures = vec![Signature::new(&sig[0..64])]; new }) @@ -138,6 +141,12 @@ fn main() { .takes_value(false) .help("Use the same payer for transfers"), ) + .arg( + Arg::with_name("same_write_account") + .long("same-write-account") + .takes_value(false) + .help("Use the destination account for transfers"), + ) .arg( Arg::with_name("iterations") .long("iterations") @@ -183,8 +192,13 @@ fn main() { info!("threads: {} txs: {}", num_threads, total_num_transactions); let same_payer = matches.is_present("same_payer"); - let mut transactions = - make_accounts_txs(total_num_transactions, genesis_config.hash(), same_payer); + let same_write_account = matches.is_present("same_write_account"); + let mut transactions = make_accounts_txs( + total_num_transactions, + genesis_config.hash(), + same_payer, + same_write_account, + ); // fund all the accounts transactions.iter().for_each(|tx| {