My code keeps getting the error 'cannot find function development_transport in crate 'libp2p'. When I go the libp2p library (click on the import statement in the editor) it shows the function development_transport in that file (lib.rs) of libp2p. Does anyone know why the function cannot be found? Thanks in advance.
use libp2p::futures::StreamExt;
use libp2p::swarm::dummy::Behaviour;
use libp2p::swarm::{Swarm, SwarmEvent};
use libp2p::{identity, PeerId};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let local_key = identity::Keypair::generate_ed25519();
let local_peer_id = PeerId::from(local_key.public());
println!("Local peer id is: {}", local_peer_id);
let behaviour = Behaviour;
let transport = libp2p::development_transport(local_key)?;
let mut swarm = Swarm::new(transport, behaviour, local_peer_id);
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
loop {
match swarm.select_next_some().await {
SwarmEvent::NewListenAddr { address, .. } => {
println!("Listening on local address {:?}", address)
}
_ => {}
}
}
}
My Cargo.toml contains the following:
[dependencies]
libp2p = "0.49.0"
tokio = { version = "1.21.2", features = ["full"] }