fn poll_swarm(&mut self) -> Poll<Option<ServiceEvent<TMessage>>, IoError> {
		loop {
			match self.swarm.poll() {
				Ok(Async::Ready(Some(BehaviourOut::CustomProtocolOpen { peer_id, version, endpoint }))) => {
					self.nodes_info.insert(peer_id.clone(), NodeInfo {
						endpoint,
						client_version: None,
						latest_ping: None,
					});
					let debug_info = self.peer_debug_info(&peer_id);
					break Ok(Async::Ready(Some(ServiceEvent::OpenedCustomProtocol {
						peer_id,
						version,
						debug_info,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::CustomProtocolClosed { peer_id, .. }))) => {
					let debug_info = self.peer_debug_info(&peer_id);
					self.nodes_info.remove(&peer_id);
					break Ok(Async::Ready(Some(ServiceEvent::ClosedCustomProtocol {
						peer_id,
						debug_info,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::CustomMessage { peer_id, message }))) => {
					break Ok(Async::Ready(Some(ServiceEvent::CustomMessage {
						peer_id,
						message,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::Clogged { peer_id, messages }))) => {
					break Ok(Async::Ready(Some(ServiceEvent::Clogged {
						peer_id,
						messages,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::Identified { peer_id, info }))) => {
					// Contrary to the other events, this one can happen even on nodes which don't
					// have any open custom protocol slot. Therefore it is not necessarily in the
					// list.
					if let Some(n) = self.nodes_info.get_mut(&peer_id) {
						n.client_version = Some(info.agent_version);
					}
				}
				Ok(Async::Ready(Some(BehaviourOut::PingSuccess { peer_id, ping_time }))) => {
					// Contrary to the other events, this one can happen even on nodes which don't
					// have any open custom protocol slot. Therefore it is not necessarily in the
					// list.
					if let Some(n) = self.nodes_info.get_mut(&peer_id) {
						n.latest_ping = Some(ping_time);
					}
				}
				Ok(Async::NotReady) => break Ok(Async::NotReady),
				Ok(Async::Ready(None)) => unreachable!("The Swarm stream never ends"),
				Err(_) => unreachable!("The Swarm never errors"),
			}
		}
	}
/// Polls for what happened on the network.
Polls for what happened on the network.
Polls for what happened on the network .
fn poll_swarm(&mut self) -> Poll<Option<ServiceEvent<TMessage>>, IoError> {
		loop {
			match self.swarm.poll() {
				Ok(Async::Ready(Some(BehaviourOut::CustomProtocolOpen { peer_id, version, endpoint }))) => {
					self.nodes_info.insert(peer_id.clone(), NodeInfo {
						endpoint,
						client_version: None,
						latest_ping: None,
					});
					let debug_info = self.peer_debug_info(&peer_id);
					break Ok(Async::Ready(Some(ServiceEvent::OpenedCustomProtocol {
						peer_id,
						version,
						debug_info,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::CustomProtocolClosed { peer_id, .. }))) => {
					let debug_info = self.peer_debug_info(&peer_id);
					self.nodes_info.remove(&peer_id);
					break Ok(Async::Ready(Some(ServiceEvent::ClosedCustomProtocol {
						peer_id,
						debug_info,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::CustomMessage { peer_id, message }))) => {
					break Ok(Async::Ready(Some(ServiceEvent::CustomMessage {
						peer_id,
						message,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::Clogged { peer_id, messages }))) => {
					break Ok(Async::Ready(Some(ServiceEvent::Clogged {
						peer_id,
						messages,
					})))
				}
				Ok(Async::Ready(Some(BehaviourOut::Identified { peer_id, info }))) => {
					// Contrary to the other events, this one can happen even on nodes which don't
					// have any open custom protocol slot. Therefore it is not necessarily in the
					// list.
					if let Some(n) = self.nodes_info.get_mut(&peer_id) {
						n.client_version = Some(info.agent_version);
					}
				}
				Ok(Async::Ready(Some(BehaviourOut::PingSuccess { peer_id, ping_time }))) => {
					// Contrary to the other events, this one can happen even on nodes which don't
					// have any open custom protocol slot. Therefore it is not necessarily in the
					// list.
					if let Some(n) = self.nodes_info.get_mut(&peer_id) {
						n.latest_ping = Some(ping_time);
					}
				}
				Ok(Async::NotReady) => break Ok(Async::NotReady),
				Ok(Async::Ready(None)) => unreachable!("The Swarm stream never ends"),
				Err(_) => unreachable!("The Swarm never errors"),
			}
		}
	}
fn poll_swarm ( & mut self ) -> Poll < Option < ServiceEvent < TMessage > > , IoError > { loop { match self . swarm . poll ( ) { Ok ( Async :: Ready ( Some ( BehaviourOut :: CustomProtocolOpen { peer_id , version , endpoint } ) ) ) => { self . nodes_info . insert ( peer_id . clone ( ) , NodeInfo { endpoint , client_version : None , latest_ping : None , } ) ; let debug_info = self . peer_debug_info ( & peer_id ) ; break Ok ( Async :: Ready ( Some ( ServiceEvent :: OpenedCustomProtocol { peer_id , version , debug_info , } ) ) ) } Ok ( Async :: Ready ( Some ( BehaviourOut :: CustomProtocolClosed { peer_id , .. } ) ) ) => { let debug_info = self . peer_debug_info ( & peer_id ) ; self . nodes_info . remove ( & peer_id ) ; break Ok ( Async :: Ready ( Some ( ServiceEvent :: ClosedCustomProtocol { peer_id , debug_info , } ) ) ) } Ok ( Async :: Ready ( Some ( BehaviourOut :: CustomMessage { peer_id , message } ) ) ) => { break Ok ( Async :: Ready ( Some ( ServiceEvent :: CustomMessage { peer_id , message , } ) ) ) } Ok ( Async :: Ready ( Some ( BehaviourOut :: Clogged { peer_id , messages } ) ) ) => { break Ok ( Async :: Ready ( Some ( ServiceEvent :: Clogged { peer_id , messages , } ) ) ) } Ok ( Async :: Ready ( Some ( BehaviourOut :: Identified { peer_id , info } ) ) ) => { // Contrary to the other events, this one can happen even on nodes which don't // have any open custom protocol slot. Therefore it is not necessarily in the // list. if let Some ( n ) = self . nodes_info . get_mut ( & peer_id ) { n . client_version = Some ( info . agent_version ) ; } } Ok ( Async :: Ready ( Some ( BehaviourOut :: PingSuccess { peer_id , ping_time } ) ) ) => { // Contrary to the other events, this one can happen even on nodes which don't // have any open custom protocol slot. Therefore it is not necessarily in the // list. if let Some ( n ) = self . nodes_info . get_mut ( & peer_id ) { n . latest_ping = Some ( ping_time ) ; } } Ok ( Async :: NotReady ) => break Ok ( Async :: NotReady ) , Ok ( Async :: Ready ( None ) ) => unreachable ! ( " " ) , Err ( _ ) => unreachable ! ( " " ) , } } }
Polls for what happened on the network.
Polls for what happened on the network .
&mut self
&mut self