Skip to content

Commit

Permalink
refactor(examples): change ipfs-kad from async-std to tokio
Browse files Browse the repository at this point in the history
Related: #4449.

Pull-Request: #4590.
  • Loading branch information
randommm authored Oct 5, 2023
1 parent 0e94bc2 commit 246acfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/ipfs-kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ publish = false
license = "MIT"

[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
tokio = { version = "1.12", features = ["rt-multi-thread", "macros"] }
async-trait = "0.1"
env_logger = "0.10"
futures = "0.3.28"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "kad", "noise", "tcp", "websocket", "yamux", "rsa"] }
libp2p = { path = "../../libp2p", features = ["tokio", "dns", "kad", "noise", "tcp", "websocket", "yamux", "rsa"] }
10 changes: 5 additions & 5 deletions examples/ipfs-kad/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use futures::StreamExt;
use libp2p::kad;
use libp2p::kad::record::store::MemoryStore;
use libp2p::{
development_transport, identity,
identity,
swarm::{SwarmBuilder, SwarmEvent},
PeerId,
tokio_development_transport, PeerId,
};
use std::{env, error::Error, time::Duration};

Expand All @@ -37,7 +37,7 @@ const BOOTNODES: [&str; 4] = [
"QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
];

#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::init();

Expand All @@ -46,7 +46,7 @@ async 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 yamux protocol
let transport = development_transport(local_key).await?;
let transport = tokio_development_transport(local_key)?;

// Create a swarm to manage peers and events.
let mut swarm = {
Expand All @@ -63,7 +63,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
behaviour.add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?);
}

SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build()
SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()
};

// Order Kademlia to search for a peer.
Expand Down

0 comments on commit 246acfd

Please sign in to comment.