mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
feat(libp2p): add SwarmBuilder
Introduce the new `libp2p::SwarmBuilder`. Users should use the new `libp2p::SwarmBuilder` instead of the now deprecated `libp2p::swarm::SwarmBuilder`. See `libp2p::SwarmBuilder` docs on how to use the new builder. Fixes #3657. Fixes #3563. Fixes #3179. Pull-Request: #4120.
This commit is contained in:
@ -33,7 +33,7 @@ use libp2p_identity::PeerId;
|
||||
use libp2p_ping as ping;
|
||||
use libp2p_plaintext as plaintext;
|
||||
use libp2p_relay as relay;
|
||||
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent};
|
||||
use libp2p_swarm::{Config, NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
@ -310,7 +310,7 @@ fn build_relay() -> Swarm<Relay> {
|
||||
|
||||
let transport = upgrade_transport(MemoryTransport::default().boxed(), &local_key);
|
||||
|
||||
SwarmBuilder::with_async_std_executor(
|
||||
Swarm::new(
|
||||
transport,
|
||||
Relay {
|
||||
ping: ping::Behaviour::new(ping::Config::new()),
|
||||
@ -323,8 +323,8 @@ fn build_relay() -> Swarm<Relay> {
|
||||
),
|
||||
},
|
||||
local_peer_id,
|
||||
Config::with_async_std_executor(),
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn build_client() -> Swarm<Client> {
|
||||
@ -337,15 +337,15 @@ fn build_client() -> Swarm<Client> {
|
||||
&local_key,
|
||||
);
|
||||
|
||||
SwarmBuilder::with_async_std_executor(
|
||||
Swarm::new(
|
||||
transport,
|
||||
Client {
|
||||
ping: ping::Behaviour::new(ping::Config::new()),
|
||||
relay: behaviour,
|
||||
},
|
||||
local_peer_id,
|
||||
Config::with_async_std_executor(),
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn upgrade_transport<StreamSink>(
|
||||
|
Reference in New Issue
Block a user