solana/bench-exchange/src/main.rs

73 lines
1.7 KiB
Rust
Raw Normal View History

2019-04-17 11:28:26 -07:00
pub mod bench;
mod cli;
pub mod order_book;
#[macro_use]
extern crate solana_exchange_program;
use crate::bench::{airdrop_lamports, do_bench_exchange, Config};
2019-04-17 11:28:26 -07:00
use log::*;
use solana::gossip_service::{discover_cluster, get_clients};
2019-04-17 11:28:26 -07:00
use solana_sdk::signature::KeypairUtil;
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().get_matches();
let cli_config = cli::extract_args(&matches);
let cli::Config {
entrypoint_addr,
2019-04-17 11:28:26 -07:00
drone_addr,
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,
..
} = cli_config;
info!("Connecting to the cluster");
let (nodes, _replicators) =
discover_cluster(&entrypoint_addr, num_nodes).unwrap_or_else(|_| {
panic!("Failed to discover nodes");
});
let clients = get_clients(&nodes);
2019-04-17 11:28:26 -07:00
info!("{} nodes found", clients.len());
if clients.len() < num_nodes {
panic!("Error: Insufficient nodes discovered");
}
2019-04-17 11:28:26 -07:00
info!("Funding keypair: {}", identity.pubkey());
debug!("Exchange program name: {}", solana_exchange_program!().0);
2019-04-17 11:28:26 -07:00
let accounts_in_groups = batch_size * account_groups;
2019-04-23 16:48:17 -07:00
const NUM_SIGNERS: u64 = 2;
2019-04-17 11:28:26 -07:00
airdrop_lamports(
&clients[0],
2019-04-17 11:28:26 -07:00
&drone_addr,
&identity,
2019-04-23 16:48:17 -07:00
fund_amount * (accounts_in_groups + 1) as u64 * NUM_SIGNERS,
2019-04-17 11:28:26 -07:00
);
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,
};
do_bench_exchange(clients, config);
2019-04-17 11:28:26 -07:00
}