pub fn network_state(&mut self) -> NetworkState {
		let swarm = &mut self.network_service;
		let open = swarm.user_protocol().open_peers().cloned().collect::<Vec<_>>();

		let connected_peers = {
			let swarm = &mut *swarm;
			open.iter().filter_map(move |peer_id| {
				let known_addresses = NetworkBehaviour::addresses_of_peer(&mut **swarm, peer_id)
					.into_iter().collect();

				let endpoint = if let Some(e) = swarm.node(peer_id).map(|i| i.endpoint()) {
					e.clone().into()
				} else {
					error!(target: "sub-libp2p", "Found state inconsistency between custom protocol \
						and debug information about {:?}", peer_id);
					return None
				};

				Some((peer_id.to_base58(), NetworkStatePeer {
					endpoint,
					version_string: swarm.node(peer_id)
						.and_then(|i| i.client_version().map(|s| s.to_owned())),
					latest_ping_time: swarm.node(peer_id).and_then(|i| i.latest_ping()),
					enabled: swarm.user_protocol().is_enabled(&peer_id),
					open: swarm.user_protocol().is_open(&peer_id),
					known_addresses,
				}))
			}).collect()
		};

		let not_connected_peers = {
			let swarm = &mut *swarm;
			swarm.known_peers().into_iter()
				.filter(|p| open.iter().all(|n| n != p))
				.map(move |peer_id| {
					(peer_id.to_base58(), NetworkStateNotConnectedPeer {
						version_string: swarm.node(&peer_id)
							.and_then(|i| i.client_version().map(|s| s.to_owned())),
						latest_ping_time: swarm.node(&peer_id).and_then(|i| i.latest_ping()),
						known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
							.into_iter().collect(),
					})
				})
				.collect()
		};

		let peer_id = Swarm::<B, H>::local_peer_id(&swarm).to_base58();
		let listened_addresses = Swarm::<B, H>::listeners(&swarm).cloned().collect();
		let external_addresses = Swarm::<B, H>::external_addresses(&swarm)
			.map(|r| &r.addr)
			.cloned()
			.collect();

		NetworkState {
			peer_id,
			listened_addresses,
			external_addresses,
			connected_peers,
			not_connected_peers,
			peerset: swarm.user_protocol_mut().peerset_debug_info(),
		}
	}
/// Get network state.
///
/// **Note**: Use this only for debugging. This API is unstable. There are warnings literally
/// everywhere about this. Please don't use this function to retrieve actual information.
Get network state.
Note**: Use this only for debugging. This API is unstable. There are warnings literally
everywhere about this. Please don't use this function to retrieve actual information.
Get network state . Note ** : Use this only for debugging . This API is unstable . There are warnings literally everywhere about this . Please don ' t use this function to retrieve actual information .
pub fn network_state(&mut self) -> NetworkState {
		let swarm = &mut self.network_service;
		let open = swarm.user_protocol().open_peers().cloned().collect::<Vec<_>>();
		let connected_peers = {
			let swarm = &mut *swarm;
			open.iter().filter_map(move |peer_id| {
				let known_addresses = NetworkBehaviour::addresses_of_peer(&mut **swarm, peer_id)
					.into_iter().collect();
				let endpoint = if let Some(e) = swarm.node(peer_id).map(|i| i.endpoint()) {
					e.clone().into()
				} else {
					error!(target: "sub-libp2p", "Found state inconsistency between custom protocol \
						and debug information about {:?}", peer_id);
					return None
				};
				Some((peer_id.to_base58(), NetworkStatePeer {
					endpoint,
					version_string: swarm.node(peer_id)
						.and_then(|i| i.client_version().map(|s| s.to_owned())),
					latest_ping_time: swarm.node(peer_id).and_then(|i| i.latest_ping()),
					enabled: swarm.user_protocol().is_enabled(&peer_id),
					open: swarm.user_protocol().is_open(&peer_id),
					known_addresses,
				}))
			}).collect()
		};
		let not_connected_peers = {
			let swarm = &mut *swarm;
			swarm.known_peers().into_iter()
				.filter(|p| open.iter().all(|n| n != p))
				.map(move |peer_id| {
					(peer_id.to_base58(), NetworkStateNotConnectedPeer {
						version_string: swarm.node(&peer_id)
							.and_then(|i| i.client_version().map(|s| s.to_owned())),
						latest_ping_time: swarm.node(&peer_id).and_then(|i| i.latest_ping()),
						known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
							.into_iter().collect(),
					})
				})
				.collect()
		};
		let peer_id = Swarm::<B, H>::local_peer_id(&swarm).to_base58();
		let listened_addresses = Swarm::<B, H>::listeners(&swarm).cloned().collect();
		let external_addresses = Swarm::<B, H>::external_addresses(&swarm)
			.map(|r| &r.addr)
			.cloned()
			.collect();
		NetworkState {
			peer_id,
			listened_addresses,
			external_addresses,
			connected_peers,
			not_connected_peers,
			peerset: swarm.user_protocol_mut().peerset_debug_info(),
		}
	}
pub fn network_state ( & mut self ) -> NetworkState { let swarm = & mut self . network_service ; let open = swarm . user_protocol ( ) . open_peers ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ; let connected_peers = { let swarm = & mut * swarm ; open . iter ( ) . filter_map ( move | peer_id | { let known_addresses = NetworkBehaviour :: addresses_of_peer ( & mut * * swarm , peer_id ) . into_iter ( ) . collect ( ) ; let endpoint = if let Some ( e ) = swarm . node ( peer_id ) . map ( | i | i . endpoint ( ) ) { e . clone ( ) . into ( ) } else { error ! ( target " " " \
 " peer_id ) ; return None } ; Some ( ( peer_id . to_base58 ( ) , NetworkStatePeer { endpoint , version_string : swarm . node ( peer_id ) . and_then ( | i | i . client_version ( ) . map ( | s | s . to_owned ( ) ) ) , latest_ping_time : swarm . node ( peer_id ) . and_then ( | i | i . latest_ping ( ) ) , enabled : swarm . user_protocol ( ) . is_enabled ( & peer_id ) , open : swarm . user_protocol ( ) . is_open ( & peer_id ) , known_addresses , } ) ) } ) . collect ( ) } ; let not_connected_peers = { let swarm = & mut * swarm ; swarm . known_peers ( ) . into_iter ( ) . filter ( | p | open . iter ( ) . all ( | n | n != p ) ) . map ( move | peer_id | { ( peer_id . to_base58 ( ) , NetworkStateNotConnectedPeer { version_string : swarm . node ( & peer_id ) . and_then ( | i | i . client_version ( ) . map ( | s | s . to_owned ( ) ) ) , latest_ping_time : swarm . node ( & peer_id ) . and_then ( | i | i . latest_ping ( ) ) , known_addresses : NetworkBehaviour :: addresses_of_peer ( & mut * * swarm , & peer_id ) . into_iter ( ) . collect ( ) , } ) } ) . collect ( ) } ; let peer_id = Swarm :: < B , H > :: local_peer_id ( & swarm ) . to_base58 ( ) ; let listened_addresses = Swarm :: < B , H > :: listeners ( & swarm ) . cloned ( ) . collect ( ) ; let external_addresses = Swarm :: < B , H > :: external_addresses ( & swarm ) . map ( | r | & r . addr ) . cloned ( ) . collect ( ) ; NetworkState { peer_id , listened_addresses , external_addresses , connected_peers , not_connected_peers , peerset : swarm . user_protocol_mut ( ) . peerset_debug_info ( ) , } }
Get network state.
Get network state .
&mut self
&mut self