mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-08-01 01:11:58 +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:
@@ -43,7 +43,8 @@ use futures::{future, prelude::*};
|
||||
use libp2p::{identity, PeerId, ping::{Ping, PingConfig}, Swarm};
|
||||
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 PeerId.
|
||||
@@ -52,7 +53,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("Local peer id: {:?}", peer_id);
|
||||
|
||||
// Create a transport.
|
||||
let transport = libp2p::build_development_transport(id_keys)?;
|
||||
let transport = libp2p::development_transport(id_keys).await?;
|
||||
|
||||
// Create a ping network behaviour.
|
||||
//
|
||||
|
Reference in New Issue
Block a user