X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fcli.rs;h=47106a0dce0193bb6fad4b7285b0299958f08a0b;hb=9c10e5533db6829deeaf26f396fc5dd493baad6c;hp=be6c80cfb0386860325ee285a1a8e67affebbf80;hpb=d4c70ceb983876b55fc2ded283f5a3e38f1c5a41;p=ldk-sample diff --git a/src/cli.rs b/src/cli.rs index be6c80c..47106a0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -401,7 +401,7 @@ fn list_channels(channel_manager: Arc) { } println!( "\t\tpeer_pubkey: {},", - hex_utils::hex_str(&chan_info.remote_network_id.serialize()) + hex_utils::hex_str(&chan_info.counterparty.node_id.serialize()) ); if let Some(id) = chan_info.short_channel_id { println!("\t\tshort_channel_id: {},", id); @@ -471,24 +471,21 @@ pub(crate) async fn connect_peer_if_necessary( } match lightning_net_tokio::connect_outbound(Arc::clone(&peer_manager), pubkey, peer_addr).await { - Some(conn_closed_fut) => { - let mut closed_fut_box = Box::pin(conn_closed_fut); - let mut peer_connected = false; - while !peer_connected { - match futures::poll!(&mut closed_fut_box) { + Some(connection_closed_future) => { + let mut connection_closed_future = Box::pin(connection_closed_future); + loop { + match futures::poll!(&mut connection_closed_future) { std::task::Poll::Ready(_) => { println!("ERROR: Peer disconnected before we finished the handshake"); return Err(()); } std::task::Poll::Pending => {} } - for node_pubkey in peer_manager.get_peer_node_ids() { - if node_pubkey == pubkey { - peer_connected = true; - } - } // Avoid blocking the tokio context by sleeping a bit - tokio::time::sleep(Duration::from_millis(10)).await; + match peer_manager.get_peer_node_ids().iter().find(|id| **id == pubkey) { + Some(_) => break, + None => tokio::time::sleep(Duration::from_millis(10)).await, + } } } None => {