protocols/mdns: Fix timely discovery after listening on new address (#2053)

If you start listening after mdns joined a multicast group, the peers may not
discover eachother until the 5min timeout expires.

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
David Craven
2021-04-21 16:07:38 +02:00
committed by GitHub
parent 40c4287bc9
commit 29d969be34
3 changed files with 11 additions and 1 deletions

View File

@ -27,6 +27,7 @@ use lazy_static::lazy_static;
use libp2p_core::{
address_translation, connection::ConnectionId, multiaddr::Protocol, Multiaddr, PeerId,
};
use libp2p_core::connection::ListenerId;
use libp2p_swarm::{
protocols_handler::DummyProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction,
PollParameters, ProtocolsHandler,
@ -269,6 +270,10 @@ impl NetworkBehaviour for Mdns {
void::unreachable(ev)
}
fn inject_new_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
self.send_buffer.push_back(build_query());
}
fn poll(
&mut self,
cx: &mut Context<'_>,