pub fn state(&mut self) -> NetworkState {
		let connected_peers = {
			let swarm = &mut self.swarm;
			self.nodes_info.iter().map(move |(peer_id, info)| {
				let known_addresses = NetworkBehaviour::addresses_of_peer(&mut **swarm, peer_id)
					.into_iter().collect();

				(peer_id.to_base58(), NetworkStatePeer {
					endpoint: info.endpoint.clone().into(),
					version_string: info.client_version.clone(),
					latest_ping_time: info.latest_ping,
					enabled: swarm.is_enabled(&peer_id),
					open: swarm.is_open(&peer_id),
					known_addresses,
				})
			}).collect()
		};

		let not_connected_peers = {
			let swarm = &mut self.swarm;
			let nodes_info = &self.nodes_info;
			let list = swarm.known_peers().filter(|p| !nodes_info.contains_key(p))
				.cloned().collect::<Vec<_>>();
			list.into_iter().map(move |peer_id| {
				(peer_id.to_base58(), NetworkStateNotConnectedPeer {
					known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
						.into_iter().collect(),
				})
			}).collect()
		};

		NetworkState {
			peer_id: Swarm::local_peer_id(&self.swarm).to_base58(),
			listened_addresses: Swarm::listeners(&self.swarm).cloned().collect(),
			external_addresses: Swarm::external_addresses(&self.swarm).cloned().collect(),
			average_download_per_sec: self.bandwidth.average_download_per_sec(),
			average_upload_per_sec: self.bandwidth.average_upload_per_sec(),
			connected_peers,
			not_connected_peers,
			peerset: self.swarm.peerset_debug_info(),
		}
	}
/// Returns a struct containing tons of useful information about the network.
Returns a struct containing tons of useful information about the network.
Returns a struct containing tons of useful information about the network .
pub fn state(&mut self) -> NetworkState {
		let connected_peers = {
			let swarm = &mut self.swarm;
			self.nodes_info.iter().map(move |(peer_id, info)| {
				let known_addresses = NetworkBehaviour::addresses_of_peer(&mut **swarm, peer_id)
					.into_iter().collect();
				(peer_id.to_base58(), NetworkStatePeer {
					endpoint: info.endpoint.clone().into(),
					version_string: info.client_version.clone(),
					latest_ping_time: info.latest_ping,
					enabled: swarm.is_enabled(&peer_id),
					open: swarm.is_open(&peer_id),
					known_addresses,
				})
			}).collect()
		};
		let not_connected_peers = {
			let swarm = &mut self.swarm;
			let nodes_info = &self.nodes_info;
			let list = swarm.known_peers().filter(|p| !nodes_info.contains_key(p))
				.cloned().collect::<Vec<_>>();
			list.into_iter().map(move |peer_id| {
				(peer_id.to_base58(), NetworkStateNotConnectedPeer {
					known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
						.into_iter().collect(),
				})
			}).collect()
		};
		NetworkState {
			peer_id: Swarm::local_peer_id(&self.swarm).to_base58(),
			listened_addresses: Swarm::listeners(&self.swarm).cloned().collect(),
			external_addresses: Swarm::external_addresses(&self.swarm).cloned().collect(),
			average_download_per_sec: self.bandwidth.average_download_per_sec(),
			average_upload_per_sec: self.bandwidth.average_upload_per_sec(),
			connected_peers,
			not_connected_peers,
			peerset: self.swarm.peerset_debug_info(),
		}
	}
pub fn state ( & mut self ) -> NetworkState { let connected_peers = { let swarm = & mut self . swarm ; self . nodes_info . iter ( ) . map ( move | ( peer_id , info ) | { let known_addresses = NetworkBehaviour :: addresses_of_peer ( & mut * * swarm , peer_id ) . into_iter ( ) . collect ( ) ; ( peer_id . to_base58 ( ) , NetworkStatePeer { endpoint : info . endpoint . clone ( ) . into ( ) , version_string : info . client_version . clone ( ) , latest_ping_time : info . latest_ping , enabled : swarm . is_enabled ( & peer_id ) , open : swarm . is_open ( & peer_id ) , known_addresses , } ) } ) . collect ( ) } ; let not_connected_peers = { let swarm = & mut self . swarm ; let nodes_info = & self . nodes_info ; let list = swarm . known_peers ( ) . filter ( | p | ! nodes_info . contains_key ( p ) ) . cloned ( ) . collect :: < Vec < _ > > ( ) ; list . into_iter ( ) . map ( move | peer_id | { ( peer_id . to_base58 ( ) , NetworkStateNotConnectedPeer { known_addresses : NetworkBehaviour :: addresses_of_peer ( & mut * * swarm , & peer_id ) . into_iter ( ) . collect ( ) , } ) } ) . collect ( ) } ; NetworkState { peer_id : Swarm :: local_peer_id ( & self . swarm ) . to_base58 ( ) , listened_addresses : Swarm :: listeners ( & self . swarm ) . cloned ( ) . collect ( ) , external_addresses : Swarm :: external_addresses ( & self . swarm ) . cloned ( ) . collect ( ) , average_download_per_sec : self . bandwidth . average_download_per_sec ( ) , average_upload_per_sec : self . bandwidth . average_upload_per_sec ( ) , connected_peers , not_connected_peers , peerset : self . swarm . peerset_debug_info ( ) , } }
Returns a struct containing tons of useful information about the network.
Returns a struct containing tons of useful information about the network .
&mut self
&mut self