fixed client demo (#325)

* fixed client demo
This commit is contained in:
anatoly yakovenko
2018-06-07 13:51:15 -07:00
committed by GitHub
parent c78132417f
commit 77c9e801aa
3 changed files with 24 additions and 18 deletions

View File

@ -109,9 +109,10 @@ fn main() {
&client_addr,
&leader,
signal.clone(),
num_nodes + 2,
num_nodes,
&mut c_threads,
);
assert_eq!(validators.len(), num_nodes);
if stdin_isatty() {
eprintln!("nothing found on stdin, expected a json file");
@ -296,26 +297,27 @@ fn converge(
gossip_send_socket,
exit.clone(),
).expect("DataReplicator::new");
//wait for the network to converge
let mut rv = vec![];
//wait for the network to converge, 30 seconds should be plenty
for _ in 0..30 {
let min = spy_ref.read().unwrap().convergence();
if num_nodes as u64 == min {
println!("converged!");
let v: Vec<ReplicatedData> = spy_ref
.read()
.unwrap()
.table
.values()
.into_iter()
.filter(|x| x.requests_addr != daddr)
.cloned()
.collect();
if v.len() >= num_nodes {
println!("CONVERGED!");
rv.extend(v.into_iter());
break;
}
sleep(Duration::new(1, 0));
}
threads.extend(data_replicator.thread_hdls.into_iter());
let v: Vec<ReplicatedData> = spy_ref
.read()
.unwrap()
.table
.values()
.into_iter()
.filter(|x| x.requests_addr != daddr)
.map(|x| x.clone())
.collect();
v.clone()
rv
}
fn read_leader(path: String) -> ReplicatedData {