Skip to content

Commit

Permalink
add option to send transfer to same account
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Apr 8, 2022
1 parent 2e5042d commit 4e6371f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fn make_accounts_txs(
total_num_transactions: usize,
hash: Hash,
same_payer: bool,
same_write_account: bool,
) -> Vec<Transaction> {
let to_pubkey = solana_sdk::pubkey::new_rand();
let payer_key = Keypair::new();
Expand All @@ -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
})
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -183,8 +192,9 @@ fn main() {
info!("threads: {} txs: {}", num_threads, total_num_transactions);

let same_payer = matches.is_present("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);
make_accounts_txs(total_num_transactions, genesis_config.hash(), same_payer, same_write_account);

// fund all the accounts
transactions.iter().for_each(|tx| {
Expand Down

0 comments on commit 4e6371f

Please sign in to comment.