The NodeId is always available in the session info (#859)

This commit is contained in:
Pierre Krieger
2018-10-01 19:31:07 +02:00
committed by Gav Wood
parent a21b2bfbb8
commit d14700f7b6
7 changed files with 10 additions and 18 deletions
+1 -4
View File
@@ -34,7 +34,6 @@ extern crate rand;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate substrate_primitives as primitives;
extern crate bytes;
extern crate unsigned_varint;
@@ -45,11 +44,9 @@ extern crate log;
#[cfg(test)] #[macro_use]
extern crate assert_matches;
use libp2p::PeerId;
pub use connection_filter::{ConnectionFilter, ConnectionDirection};
pub use error::{Error, ErrorKind, DisconnectReason};
pub use libp2p::{Multiaddr, multiaddr::Protocol};
pub use libp2p::{Multiaddr, multiaddr::Protocol, PeerId};
pub use traits::*;
pub type TimerToken = usize;
+1 -1
View File
@@ -552,7 +552,7 @@ impl NetworkContext for NetworkContextImpl {
};
Some(SessionInfo {
id: None, // TODO: ???? what to do??? wrong format!
id: info.id.clone(),
client_version: info.client_version.clone().take().unwrap_or(String::new()),
protocol_version: From::from(protocol_version),
capabilities: Vec::new(), // TODO: list of supported protocols ; hard
+3 -4
View File
@@ -21,9 +21,8 @@ use std::net::Ipv4Addr;
use std::str;
use std::time::Duration;
use TimerToken;
use libp2p::{multiaddr::Protocol, Multiaddr};
use libp2p::{multiaddr::Protocol, Multiaddr, PeerId};
use error::Error;
use primitives::hash::H512;
/// Protocol handler level packet id
pub type PacketId = u8;
@@ -31,7 +30,7 @@ pub type PacketId = u8;
pub type ProtocolId = [u8; 3];
/// Node public key
pub type NodeId = H512;
pub type NodeId = PeerId;
/// Local (temporary) peer session ID.
pub type NodeIndex = usize;
@@ -43,7 +42,7 @@ pub type Secret = [u8; 32];
#[derive(Debug, Clone)]
pub struct SessionInfo {
/// Peer public key
pub id: Option<NodeId>,
pub id: NodeId,
/// Peer client ID
pub client_version: String,
/// Peer RLPx protocol version