Skip to content

Commit

Permalink
wip4
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalence committed Oct 10, 2019
1 parent b6101eb commit 7584c36
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions zebrad/src/commands/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,25 @@ impl ConnectCmd {
info!("waiting for peer_set ready");
peer_set.ready().await.map_err(Error::from_boxed_compat)?;

let addrs = match client.call(Request::GetPeers).await? {
Response::Peers(addrs) => addrs,
_ => bail!("Got wrong response type"),
};
info!(
addrs.len = addrs.len(),
"got addresses from peerset connected peer"
);
info!("peer_set became ready, constructing addr requests");

let mut addr_reqs = FuturesUnordered::new();
for i in 0..10usize {
info!(i, "awaiting peer_set ready");
peer_set.ready().await.map_err(Error::from_boxed_compat)?;
info!(i, "calling peer_set");
addr_reqs.push(peer_set.call(Request::GetPeers));
}

let mut all_addrs = Vec::new();
while let Some(Ok(Response::Peers(addrs))) = addr_reqs.next().await {
info!(
all_addrs.len = all_addrs.len(),
addrs.len = addrs.len(),
"got address response"
);
all_addrs.extend(addrs);
}

loop {
// empty loop ensures we don't exit the application,
Expand Down

0 comments on commit 7584c36

Please sign in to comment.