From bbce08a67b0939fefb364987b9d68bf10374cca5 Mon Sep 17 00:00:00 2001 From: Anatoly Yakovenko Date: Mon, 27 Aug 2018 05:14:50 +0000 Subject: [PATCH] bench needs to discover leader as well --- src/bin/bench-tps.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/bin/bench-tps.rs b/src/bin/bench-tps.rs index 66b045c9e1..96675abe5e 100644 --- a/src/bin/bench-tps.rs +++ b/src/bin/bench-tps.rs @@ -283,8 +283,8 @@ fn airdrop_tokens(client: &mut ThinClient, leader: &NodeInfo, id: &Keypair, tx_c if starting_balance < tx_count { let airdrop_amount = tx_count - starting_balance; println!( - "Airdropping {:?} tokens from {}", - airdrop_amount, drone_addr + "Airdropping {:?} tokens from {} for {}", + airdrop_amount, drone_addr, id.pubkey(), ); request_airdrop(&drone_addr, &id.pubkey(), airdrop_amount as u64).unwrap(); @@ -304,7 +304,7 @@ fn airdrop_tokens(client: &mut ThinClient, leader: &NodeInfo, id: &Keypair, tx_c } metrics_submit_token_balance(current_balance); if current_balance - starting_balance != airdrop_amount { - println!("Airdrop failed!"); + println!("Airdrop failed! {} {} {}", id.pubkey(), current_balance, starting_balance); exit(1); } } @@ -495,7 +495,7 @@ fn main() { let exit_signal = Arc::new(AtomicBool::new(false)); let mut c_threads = vec![]; - let validators = converge(&leader, &exit_signal, num_nodes, &mut c_threads, addr); + let (validators, leader) = converge(&leader, &exit_signal, num_nodes, &mut c_threads, addr); println!(" Node address | Node identifier"); println!("----------------------+------------------"); @@ -515,11 +515,16 @@ fn main() { ); exit(1); } + if leader.is_none() { + println!("no leader"); + } if matches.is_present("converge_only") { return; } + let leader = leader.unwrap(); + println!("leader is at {} {}", leader.contact_info.rpu, leader.id); let mut client = mk_client(&leader); let mut barrier_client = mk_client(&leader); @@ -656,7 +661,7 @@ fn converge( num_nodes: usize, threads: &mut Vec>, addr: IpAddr, -) -> Vec { +) -> (Vec, Option) { //lets spy on the network let (node, gossip_socket, gossip_send_socket) = Crdt::spy_node(addr); let mut spy_crdt = Crdt::new(node).expect("Crdt::new"); @@ -675,6 +680,12 @@ fn converge( let mut v: Vec = vec![]; //wait for the network to converge, 30 seconds should be plenty for _ in 0..30 { + if spy_ref + .read() + .unwrap().leader_data().is_none() { + continue; + } + v = spy_ref .read() .unwrap() @@ -683,6 +694,7 @@ fn converge( .filter(|x| Crdt::is_valid_address(x.contact_info.rpu)) .cloned() .collect(); + if v.len() >= num_nodes { println!("CONVERGED!"); break; @@ -696,7 +708,8 @@ fn converge( sleep(Duration::new(1, 0)); } threads.extend(ncp.thread_hdls().into_iter()); - v + let leader = spy_ref.read().unwrap().leader_data().cloned(); + (v,leader) } fn read_leader(path: &str) -> Config {