mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-23 16:11:19 +00:00
fix(examples/file-sharing): set Kademlia Mode::Server
Explicitly set `libp2p-kad` `Kademlia::set_mode` to `Mode::Server` to reduce complexity of example, i.e. not having to explicitly set external addresses. Pull-Request: #4197.
This commit is contained in:
parent
c86b665a65
commit
fbf35e14cb
@ -7,7 +7,8 @@ use libp2p::{
|
|||||||
core::Multiaddr,
|
core::Multiaddr,
|
||||||
identity,
|
identity,
|
||||||
kad::{
|
kad::{
|
||||||
record::store::MemoryStore, GetProvidersOk, Kademlia, KademliaEvent, QueryId, QueryResult,
|
self, record::store::MemoryStore, GetProvidersOk, Kademlia, KademliaEvent, QueryId,
|
||||||
|
QueryResult,
|
||||||
},
|
},
|
||||||
multiaddr::Protocol,
|
multiaddr::Protocol,
|
||||||
noise,
|
noise,
|
||||||
@ -52,7 +53,7 @@ pub(crate) async fn new(
|
|||||||
|
|
||||||
// Build the Swarm, connecting the lower layer transport logic with the
|
// Build the Swarm, connecting the lower layer transport logic with the
|
||||||
// higher layer network behaviour logic.
|
// higher layer network behaviour logic.
|
||||||
let swarm = SwarmBuilder::with_async_std_executor(
|
let mut swarm = SwarmBuilder::with_async_std_executor(
|
||||||
transport,
|
transport,
|
||||||
ComposedBehaviour {
|
ComposedBehaviour {
|
||||||
kademlia: Kademlia::new(peer_id, MemoryStore::new(peer_id)),
|
kademlia: Kademlia::new(peer_id, MemoryStore::new(peer_id)),
|
||||||
@ -68,6 +69,11 @@ pub(crate) async fn new(
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
swarm
|
||||||
|
.behaviour_mut()
|
||||||
|
.kademlia
|
||||||
|
.set_mode(Some(kad::Mode::Server));
|
||||||
|
|
||||||
let (command_sender, command_receiver) = mpsc::channel(0);
|
let (command_sender, command_receiver) = mpsc::channel(0);
|
||||||
let (event_sender, event_receiver) = mpsc::channel(0);
|
let (event_sender, event_receiver) = mpsc::channel(0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user