Skip to content
Snippets Groups Projects
Commit 90eef10d authored by Pierre Krieger's avatar Pierre Krieger Committed by Bastian Köcher
Browse files

Address review in #1884 (#1906)

parent 2e9b2be8
No related merge requests found
...@@ -118,12 +118,12 @@ pub enum NetworkStatePeerEndpoint { ...@@ -118,12 +118,12 @@ pub enum NetworkStatePeerEndpoint {
impl From<ConnectedPoint> for NetworkStatePeerEndpoint { impl From<ConnectedPoint> for NetworkStatePeerEndpoint {
fn from(endpoint: ConnectedPoint) -> Self { fn from(endpoint: ConnectedPoint) -> Self {
match endpoint { match endpoint {
ConnectedPoint::Dialer { ref address } => ConnectedPoint::Dialer { address } =>
NetworkStatePeerEndpoint::Dialing(address.clone()), NetworkStatePeerEndpoint::Dialing(address),
ConnectedPoint::Listener { ref listen_addr, ref send_back_addr } => ConnectedPoint::Listener { listen_addr, send_back_addr } =>
NetworkStatePeerEndpoint::Listening { NetworkStatePeerEndpoint::Listening {
listen_addr: listen_addr.clone(), listen_addr: listen_addr,
send_back_addr: send_back_addr.clone() send_back_addr: send_back_addr
} }
} }
} }
......
...@@ -25,7 +25,7 @@ use futures::{prelude::*, Stream}; ...@@ -25,7 +25,7 @@ use futures::{prelude::*, Stream};
use libp2p::{multiaddr::Protocol, Multiaddr, PeerId, build_multiaddr}; use libp2p::{multiaddr::Protocol, Multiaddr, PeerId, build_multiaddr};
use libp2p::core::{Swarm, nodes::Substream, transport::boxed::Boxed, muxing::StreamMuxerBox}; use libp2p::core::{Swarm, nodes::Substream, transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::core::nodes::ConnectedPoint; use libp2p::core::nodes::ConnectedPoint;
use log::{debug, info, warn}; use log::{debug, error, info, warn};
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::fs; use std::fs;
use std::io::{Error as IoError, ErrorKind as IoErrorKind}; use std::io::{Error as IoError, ErrorKind as IoErrorKind};
...@@ -477,9 +477,12 @@ where TMessage: CustomMessage + Send + 'static { ...@@ -477,9 +477,12 @@ where TMessage: CustomMessage + Send + 'static {
// have any open custom protocol slot. Therefore it is not necessarily in the // have any open custom protocol slot. Therefore it is not necessarily in the
// list. // list.
if let Some(id) = self.index_by_id.get(&peer_id) { if let Some(id) = self.index_by_id.get(&peer_id) {
self.nodes_info.get_mut(id) if let Some(n) = self.nodes_info.get_mut(id) {
.expect("index_by_id and nodes_info are always kept in sync; QED") n.client_version = Some(info.agent_version);
.client_version = Some(info.agent_version); } else {
error!(target: "sub-libp2p",
"State inconsistency between index_by_id and nodes_info");
}
} }
} }
Ok(Async::Ready(Some(BehaviourOut::PingSuccess { peer_id, ping_time }))) => { Ok(Async::Ready(Some(BehaviourOut::PingSuccess { peer_id, ping_time }))) => {
...@@ -487,9 +490,12 @@ where TMessage: CustomMessage + Send + 'static { ...@@ -487,9 +490,12 @@ where TMessage: CustomMessage + Send + 'static {
// have any open custom protocol slot. Therefore it is not necessarily in the // have any open custom protocol slot. Therefore it is not necessarily in the
// list. // list.
if let Some(id) = self.index_by_id.get(&peer_id) { if let Some(id) = self.index_by_id.get(&peer_id) {
self.nodes_info.get_mut(id) if let Some(n) = self.nodes_info.get_mut(id) {
.expect("index_by_id and nodes_info are always kept in sync; QED") n.latest_ping = Some(ping_time);
.latest_ping = Some(ping_time); } else {
error!(target: "sub-libp2p",
"State inconsistency between index_by_id and nodes_info");
}
} }
} }
Ok(Async::NotReady) => break Ok(Async::NotReady), Ok(Async::NotReady) => break Ok(Async::NotReady),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment