mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-19 21:11:22 +00:00
[libp2p-dns] Use trust-dns-resolver (with either async-std or tokio). Remove thread pool. (#1927)
* [libp2p-dns] Use trust-dns-resolver. Use the `trust-dns-resolver` library for DNS resolution, thereby removing current use of the thread pool. Since `trust-dns-resolver` and related crates already provide support for both `async-std` and `tokio`, we make use of that here in our own feature flags. Since `trust-dns-resolver` provides many useful configuration options and error detail, central types of `trust-dns-resolver` like `ResolverConfig`, `ResolverOpts` and `ResolveError` are re-exposed in the API of `libp2p-dns`. Full encapsulation does not seem preferable in this case. * Cleanup * Fix two intra-doc links. * Simplify slightly. * Incorporate review feedback. * Remove git dependency and fix example. * Update version and changelogs.
This commit is contained in:
@ -58,14 +58,15 @@ use libp2p::{
|
||||
NetworkBehaviour,
|
||||
PeerId,
|
||||
Swarm,
|
||||
build_development_transport,
|
||||
development_transport,
|
||||
identity,
|
||||
mdns::{Mdns, MdnsConfig, MdnsEvent},
|
||||
swarm::NetworkBehaviourEventProcess
|
||||
};
|
||||
use std::{error::Error, task::{Context, Poll}};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
#[async_std::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
env_logger::init();
|
||||
|
||||
// Create a random key for ourselves.
|
||||
@ -73,7 +74,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let local_peer_id = PeerId::from(local_key.public());
|
||||
|
||||
// Set up a an encrypted DNS-enabled TCP Transport over the Mplex protocol.
|
||||
let transport = build_development_transport(local_key)?;
|
||||
let transport = development_transport(local_key).await?;
|
||||
|
||||
// We create a custom network behaviour that combines Kademlia and mDNS.
|
||||
#[derive(NetworkBehaviour)]
|
||||
|
Reference in New Issue
Block a user