From 5137e4e4e710aaf3c38c2507a4e65b76d99a4834 Mon Sep 17 00:00:00 2001 From: P1R0 Date: Tue, 3 Sep 2024 16:58:15 -0600 Subject: [PATCH] refactor(examples): use tokio instead of async-std in identify example (#5579) ## Description Following on issue #4449 refactor: use tokio instead of async-std in the identify example and remove unnecesary dependencies ## Notes & open questions ## Change checklist * Removed unnecessary dependencies on examples/identify/Cargo.toml - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates --------- Co-authored-by: David E. Perez Negron R. Co-authored-by: Darius Clark --- Cargo.lock | 3 +-- examples/identify/Cargo.toml | 5 ++--- examples/identify/src/main.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c8eae458fc..5c419ed0348 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2311,10 +2311,9 @@ dependencies = [ name = "identify-example" version = "0.1.0" dependencies = [ - "async-std", - "async-trait", "futures", "libp2p", + "tokio", "tracing", "tracing-subscriber", ] diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml index cbe569b9d07..8d12699afa7 100644 --- a/examples/identify/Cargo.toml +++ b/examples/identify/Cargo.toml @@ -9,10 +9,9 @@ license = "MIT" release = false [dependencies] -async-std = { version = "1.12", features = ["attributes"] } -async-trait = "0.1" +tokio = { version = "1.37.0", features = ["full"] } futures = { workspace = true } -libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] } +libp2p = { path = "../../libp2p", features = ["identify", "noise", "tcp", "tokio", "yamux"] } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/examples/identify/src/main.rs b/examples/identify/src/main.rs index 916317a5a43..22474061da6 100644 --- a/examples/identify/src/main.rs +++ b/examples/identify/src/main.rs @@ -25,14 +25,14 @@ use libp2p::{core::multiaddr::Multiaddr, identify, noise, swarm::SwarmEvent, tcp use std::{error::Error, time::Duration}; use tracing_subscriber::EnvFilter; -#[async_std::main] +#[tokio::main] async fn main() -> Result<(), Box> { let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) .try_init(); let mut swarm = libp2p::SwarmBuilder::with_new_identity() - .with_async_std() + .with_tokio() .with_tcp( tcp::Config::default(), noise::Config::new,