solana/bench-exchange/src/main.rs

83 lines
2.2 KiB
Rust
Raw Normal View History

2019-04-17 11:28:26 -07:00
pub mod bench;
mod cli;
pub mod order_book;
use crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config};
2019-04-17 11:28:26 -07:00
use log::*;
2019-08-21 10:23:33 -07:00
use solana_core::gossip_service::{discover_cluster, get_multi_client};
use solana_sdk::signature::Signer;
2019-04-17 11:28:26 -07:00
fn main() {
solana_logger::setup();
solana_metrics::set_panic_hook("bench-exchange");
2019-04-17 11:28:26 -07:00
let matches = cli::build_args(solana_version::version!()).get_matches();
2019-04-17 11:28:26 -07:00
let cli_config = cli::extract_args(&matches);
let cli::Config {
entrypoint_addr,
2019-12-16 13:05:17 -08:00
faucet_addr,
2019-04-17 11:28:26 -07:00
identity,
threads,
num_nodes,
duration,
2019-04-23 16:48:17 -07:00
transfer_delay,
2019-04-17 11:28:26 -07:00
fund_amount,
batch_size,
2019-04-23 16:48:17 -07:00
chunk_size,
2019-04-17 11:28:26 -07:00
account_groups,
client_ids_and_stake_file,
write_to_client_file,
read_from_client_file,
2019-04-17 11:28:26 -07:00
..
} = cli_config;
let config = Config {
identity,
threads,
duration,
2019-04-23 16:48:17 -07:00
transfer_delay,
2019-04-17 11:28:26 -07:00
fund_amount,
batch_size,
2019-04-23 16:48:17 -07:00
chunk_size,
2019-04-17 11:28:26 -07:00
account_groups,
client_ids_and_stake_file,
read_from_client_file,
2019-04-17 11:28:26 -07:00
};
if write_to_client_file {
create_client_accounts_file(
&config.client_ids_and_stake_file,
config.batch_size,
config.account_groups,
config.fund_amount,
);
} else {
info!("Connecting to the cluster");
let nodes = discover_cluster(&entrypoint_addr, num_nodes).unwrap_or_else(|_| {
panic!("Failed to discover nodes");
});
let (client, num_clients) = get_multi_client(&nodes);
info!("{} nodes found", num_clients);
if num_clients < num_nodes {
panic!("Error: Insufficient nodes discovered");
}
if !read_from_client_file {
info!("Funding keypair: {}", config.identity.pubkey());
let accounts_in_groups = batch_size * account_groups;
const NUM_SIGNERS: u64 = 2;
airdrop_lamports(
&client,
2019-12-16 13:05:17 -08:00
&faucet_addr,
&config.identity,
fund_amount * (accounts_in_groups + 1) as u64 * NUM_SIGNERS,
);
}
do_bench_exchange(vec![client], config);
}
2019-04-17 11:28:26 -07:00
}