Skip to content
Snippets Groups Projects
Commit 5777aad1 authored by Wei Tang's avatar Wei Tang
Browse files

Fix network interface update

parent 39769e97
No related merge requests found
Pipeline #56093 failed with stage
in 5 minutes and 38 seconds
......@@ -174,7 +174,7 @@ impl<C: Config, TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess
{
fn inject_event(&mut self, event: IdentifyEvent) {
match event {
IdentifyEvent::Identified {
IdentifyEvent::Received {
peer_id, mut info, ..
} => {
if info.listen_addrs.len() > MAX_IDENTIFY_ADDRESSES {
......@@ -192,9 +192,9 @@ impl<C: Config, TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess
info.protocols,
);
self.events.push(Libp2pEvent::PeerDialed(peer_id));
}
IdentifyEvent::Error { .. } => {}
IdentifyEvent::SendBack { .. } => {}
},
IdentifyEvent::Sent { .. } => (),
IdentifyEvent::Error { .. } => (),
}
}
}
......
......@@ -268,7 +268,7 @@ fn load_enr(
// Build the local ENR.
// Note: Discovery should update the ENR record's IP to the external IP as seen by the
// majority of our peers.
let local_enr = EnrBuilder::new()
let local_enr = EnrBuilder::new("v4")
.ip(config.discovery_address)
.tcp(config.libp2p_port)
.udp(config.discovery_port)
......
......@@ -154,23 +154,15 @@ fn build_transport(local_private_key: Keypair) -> Boxed<(PeerId, StreamMuxerBox)
transport.or_transport(websocket::WsConfig::new(trans_clone))
};
transport
.with_upgrade(secio::SecioConfig::new(local_private_key))
.and_then(move |out, endpoint| {
let peer_id = out.remote_key.into_peer_id();
let peer_id2 = peer_id.clone();
let upgrade = core::upgrade::SelectUpgrade::new(
libp2p::yamux::Config::default(),
libp2p::mplex::MplexConfig::new(),
)
// TODO: use a single `.map` instead of two maps
.map_inbound(move |muxer| (peer_id, muxer))
.map_outbound(move |muxer| (peer_id2, muxer));
core::upgrade::apply(out.stream, upgrade, endpoint)
.map(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer)))
})
.with_timeout(Duration::from_secs(20))
.map_err(|err| Error::Libp2p(Box::new(err)))
.upgrade(core::upgrade::Version::V1)
.authenticate(secio::SecioConfig::new(local_private_key))
.multiplex(core::upgrade::SelectUpgrade::new(
libp2p::yamux::Config::default(),
libp2p::mplex::MplexConfig::new(),
))
.map(|(peer, muxer), _| (peer, core::muxing::StreamMuxerBox::new(muxer)))
.timeout(Duration::from_secs(20))
.map_err(|e| Error::Libp2p(Box::new(e)))
.boxed()
}
......
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