mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 09:21:02 +00:00
committed by
Bastian Köcher
parent
2e9b2be8fa
commit
90eef10d5c
@@ -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};
|
|||||||
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 {
|
|||||||
// 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 {
|
|||||||
// 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),
|
||||||
|
|||||||
Reference in New Issue
Block a user