mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 09:31:20 +00:00
Add a few more methods to Swarm and PollParameters (#721)
This commit is contained in:
@ -56,10 +56,11 @@ use libp2p::{
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
// Create a random PeerId
|
||||
let local_key = secio::SecioKeyPair::ed25519_generated().unwrap();
|
||||
let local_peer_id = local_key.to_peer_id();
|
||||
println!("Local peer id: {:?}", local_peer_id);
|
||||
let local_pub_key = local_key.to_public_key();
|
||||
println!("Local peer id: {:?}", local_pub_key.clone().into_peer_id());
|
||||
|
||||
// Set up a an encrypted DNS-enabled TCP Transport over the Mplex protocol
|
||||
let transport = libp2p::CommonTransport::new()
|
||||
@ -75,9 +76,9 @@ fn main() {
|
||||
|
||||
// Create a Swarm to manage peers and events
|
||||
let mut swarm = {
|
||||
let mut behaviour = libp2p::floodsub::FloodsubBehaviour::new(local_peer_id);
|
||||
let mut behaviour = libp2p::floodsub::FloodsubBehaviour::new(local_pub_key.clone().into_peer_id());
|
||||
behaviour.subscribe(floodsub_topic.clone());
|
||||
libp2p::Swarm::new(transport, behaviour, libp2p::core::topology::MemoryTopology::empty())
|
||||
libp2p::Swarm::new(transport, behaviour, libp2p::core::topology::MemoryTopology::empty(), local_pub_key)
|
||||
};
|
||||
|
||||
// Listen on all interfaces and whatever port the OS assigns
|
||||
|
Reference in New Issue
Block a user