Complete merging of network addition branch

This commit is contained in:
Age Manning
2019-06-23 12:34:00 +10:00
parent cf459b60a9
commit 84ea5adffe
11 changed files with 12 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ edition = "2018"
beacon_chain = { path = "../beacon_chain" }
clap = "2.32.0"
# SigP repository
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "8d5e5bbbe32d07ad271d6a2e15fde0347894061a" }
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "71744d4090ebd93a993d1b390787919add4098fd" }
types = { path = "../../eth2/types" }
serde = "1.0"
serde_derive = "1.0"

View File

@@ -111,14 +111,16 @@ impl<TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess<IdentifyEv
);
info.listen_addrs.truncate(20);
}
self.events
.push(BehaviourEvent::Identified(peer_id, Box::new(info)));
trace!(self.log, "Found addresses"; "Peer Id" => format!("{:?}", peer_id), "Addresses" => format!("{:?}", info.listen_addrs));
// inject the found addresses into our discovery behaviour
for address in &info.listen_addrs {
self.discovery
.add_connected_address(&peer_id, address.clone());
}
self.events
.push(BehaviourEvent::Identified(peer_id, Box::new(info)));
}
IdentifyEvent::Error { .. } => {}
IdentifyEvent::SendBack { .. } => {}

View File

@@ -1,8 +1,8 @@
use clap::ArgMatches;
use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder};
use libp2p::multiaddr::{Error as MultiaddrError, Multiaddr};
use serde_derive::{Deserialize, Serialize};
use std::time::Duration;
use types::multiaddr::{Error as MultiaddrError, Multiaddr};
/// The beacon node topic string to subscribe to.
pub const BEACON_PUBSUB_TOPIC: &str = "beacon_node";

View File

@@ -55,7 +55,7 @@ impl<TSubstream> Discovery<TSubstream> {
/// We have discovered an address for a peer, add it to known peers.
pub fn add_connected_address(&mut self, peer_id: &PeerId, address: Multiaddr) {
// pass the address on to kademlia
self.discovery.add_connected_address(peer_id, address);
self.discovery.add_address(peer_id, address);
}
}