mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-23 14:51:34 +00:00
Adds support for handling interface changes to mdns behaviour. (#1830)
* mdns: handle address changes. * Update examples. * Use async-io. * Fix tokio-chat. * Address review comments. * Update if-watch. * Poll interfaces correctly. * Use socket2 and remove wasm-time. * Update if-watch. * Update versions and changelogs. * Further changelog updates. Co-authored-by: Roman Borschel <romanb@users.noreply.github.com> Co-authored-by: Roman S. Borschel <roman@parity.io>
This commit is contained in:
@ -46,8 +46,7 @@ use libp2p::{
|
||||
core::upgrade,
|
||||
identity,
|
||||
floodsub::{self, Floodsub, FloodsubEvent},
|
||||
// `TokioMdns` is available through the `mdns-tokio` feature.
|
||||
mdns::{TokioMdns, MdnsEvent},
|
||||
mdns::{Mdns, MdnsEvent},
|
||||
mplex,
|
||||
noise,
|
||||
swarm::{NetworkBehaviourEventProcess, SwarmBuilder},
|
||||
@ -90,7 +89,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
#[derive(NetworkBehaviour)]
|
||||
struct MyBehaviour {
|
||||
floodsub: Floodsub,
|
||||
mdns: TokioMdns,
|
||||
mdns: Mdns,
|
||||
}
|
||||
|
||||
impl NetworkBehaviourEventProcess<FloodsubEvent> for MyBehaviour {
|
||||
@ -122,7 +121,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Create a Swarm to manage peers and events.
|
||||
let mut swarm = {
|
||||
let mdns = TokioMdns::new()?;
|
||||
let mdns = Mdns::new().await?;
|
||||
let mut behaviour = MyBehaviour {
|
||||
floodsub: Floodsub::new(peer_id.clone()),
|
||||
mdns,
|
||||
@ -172,4 +171,4 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user