Skip to content

Commit fd09835

Browse files
chore(relay): move server example to examples/
Related: #3111. Pull-Request: #3663.
1 parent d652c01 commit fd09835

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

Cargo.lock

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"examples/ipfs-kad",
1111
"examples/ipfs-private",
1212
"examples/ping-example",
13+
"examples/relay-server",
1314
"examples/rendezvous",
1415
"identity",
1516
"interop-tests",

examples/relay-server/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "relay-server-example"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
license = "MIT"
7+
8+
[dependencies]
9+
clap = { version = "4.1.11", features = ["derive"] }
10+
async-std = { version = "1.12", features = ["attributes"] }
11+
async-trait = "0.1"
12+
env_logger = "0.10.0"
13+
futures = "0.3.27"
14+
libp2p = { path = "../../libp2p", features = ["async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay"] }

protocols/relay/examples/relay.rs renamed to examples/relay-server/src/main.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
use clap::Parser;
2323
use futures::executor::block_on;
2424
use futures::stream::StreamExt;
25-
use libp2p_core::multiaddr::Protocol;
26-
use libp2p_core::upgrade;
27-
use libp2p_core::{Multiaddr, Transport};
28-
use libp2p_identify as identify;
29-
use libp2p_identity as identity;
30-
use libp2p_identity::PeerId;
31-
use libp2p_noise as noise;
32-
use libp2p_ping as ping;
33-
use libp2p_relay as relay;
34-
use libp2p_swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent};
35-
use libp2p_tcp as tcp;
25+
use libp2p::{
26+
core::multiaddr::Protocol,
27+
core::upgrade,
28+
core::{Multiaddr, Transport},
29+
identify, identity,
30+
identity::PeerId,
31+
noise, ping, relay,
32+
swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
33+
tcp,
34+
};
3635
use std::error::Error;
3736
use std::net::{Ipv4Addr, Ipv6Addr};
3837

@@ -55,7 +54,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5554
noise::NoiseAuthenticated::xx(&local_key)
5655
.expect("Signing libp2p-noise static DH keypair failed."),
5756
)
58-
.multiplex(libp2p_yamux::YamuxConfig::default())
57+
.multiplex(libp2p::yamux::YamuxConfig::default())
5958
.boxed();
6059

6160
let behaviour = Behaviour {
@@ -94,7 +93,6 @@ fn main() -> Result<(), Box<dyn Error>> {
9493
}
9594

9695
#[derive(NetworkBehaviour)]
97-
#[behaviour(prelude = "libp2p_swarm::derive_prelude")]
9896
struct Behaviour {
9997
relay: relay::Behaviour,
10098
ping: ping::Behaviour,

protocols/relay/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ thiserror = "1.0"
2929
void = "1"
3030

3131
[dev-dependencies]
32-
clap = { version = "4.1.11", features = ["derive"] }
3332
env_logger = "0.10.0"
34-
libp2p-identify = { path = "../../protocols/identify" }
35-
libp2p-noise = { path = "../../transports/noise" }
3633
libp2p-ping = { path = "../../protocols/ping" }
3734
libp2p-plaintext = { path = "../../transports/plaintext" }
3835
libp2p-swarm = { path = "../../swarm", features = ["macros"] }
39-
libp2p-tcp = { path = "../../transports/tcp", features = ["async-io"] }
4036
libp2p-yamux = { path = "../../muxers/yamux" }
4137
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
4238

0 commit comments

Comments
 (0)