Skip to content

Commit 7b72369

Browse files
committed
refactor: move relay-server to a different crate
1 parent 1eb752e commit 7b72369

14 files changed

Lines changed: 71 additions & 30 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"crates/charon-p2p",
1313
"crates/charon-testutil",
1414
"crates/tracing",
15+
"crates/relay-server"
1516
]
1617
resolver = "3"
1718

@@ -65,6 +66,7 @@ charon-k1util = { path = "crates/charon-k1util" }
6566
charon-p2p = { path = "crates/charon-p2p" }
6667
charon-testutil = { path = "crates/charon-testutil" }
6768
charon-tracing = { path = "crates/tracing" }
69+
charon-relay-server = { path = "crates/relay-server" }
6870

6971
[workspace.lints.rust]
7072
missing_docs = "deny"

crates/charon-p2p/src/behaviours/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ pub mod pluto;
77
#[cfg(feature = "mdns")]
88
/// Pluto Mdns behaviour.
99
pub mod pluto_mdns;
10-
11-
/// Relay server behaviour.
12-
pub mod relay_server;

crates/charon-p2p/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,3 @@ pub mod behaviours;
2828

2929
/// K1 utilities.
3030
pub mod k1;
31-
32-
/// Everything related to relay client / server.
33-
pub mod relay;

crates/relay-server/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "charon-relay-server"
3+
version.workspace = true
4+
edition.workspace = true
5+
repository.workspace = true
6+
license.workspace = true
7+
publish.workspace = true
8+
9+
[dependencies]
10+
axum.workspace = true
11+
libp2p.workspace = true
12+
thiserror.workspace = true
13+
k256.workspace = true
14+
charon-eth2.workspace = true
15+
vise.workspace = true
16+
tokio.workspace = true
17+
tokio-util.workspace = true
18+
rand.workspace = true
19+
charon-tracing.workspace = true
20+
tracing.workspace = true
21+
charon-p2p.workspace = true
22+
23+
[dev-dependencies]
24+
vise-exporter.workspace = true
25+
26+
[lints]
27+
workspace = true

crates/charon-p2p/examples/relay_server.rs renamed to crates/relay-server/examples/relay_server.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#![allow(missing_docs)]
22
use std::str::FromStr;
33

4-
use charon_p2p::{
5-
config::P2PConfig,
6-
relay::{config::Config, p2p::run_relay_p2p_node},
7-
};
4+
use charon_p2p::config::P2PConfig;
5+
use charon_relay_server::{config::Config, p2p::run_relay_p2p_node};
86
use charon_tracing::TracingConfig;
97
use k256::SecretKey;
108
use libp2p::multiaddr;

crates/charon-p2p/src/behaviours/relay_server.rs renamed to crates/relay-server/src/behaviour.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#![allow(missing_docs)] // we need to allow missing docs for the derive macro
12
//! Relay server behaviour.
23
34
use std::time::Duration;
45

56
use libp2p::{identify, identity::Keypair, ping, relay, swarm::NetworkBehaviour};
67

7-
use crate::gater::ConnGater;
8+
use charon_p2p::gater::ConnGater;
89

910
/// Relay server network behaviour.
1011
#[derive(NetworkBehaviour)]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{path::PathBuf, time::Duration};
33
use charon_tracing::TracingConfig;
44
use libp2p::relay;
55

6-
use crate::config::P2PConfig;
6+
use charon_p2p::config::P2PConfig;
77

88
/// One hour in seconds.
99
pub const ONE_HOUR_SECONDS: u64 = 60 * 60;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use libp2p::multiaddr;
22

3-
use crate::p2p::P2PError;
3+
use charon_p2p::p2p::P2PError;
44

55
/// Relay P2P error.
66
#[derive(Debug, thiserror::Error)]
77
pub enum RelayP2PError {
88
/// Failed to load private key.
99
#[error("Failed to load private key")]
10-
FailedToLoadPrivateKey(#[from] crate::k1::K1Error),
10+
FailedToLoadPrivateKey(#[from] charon_p2p::k1::K1Error),
1111

1212
/// P2P error.
1313
#[error("P2P error: {0}")]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub mod error;
1818
/// Utils.
1919
pub mod utils;
2020

21+
/// Behaviour.
22+
pub mod behaviour;
23+
2124
pub use error::RelayP2PError;
2225

2326
pub(crate) use error::Result;

0 commit comments

Comments
 (0)