Skip to content

Commit

Permalink
refact: replace litep2p with libp2p-rs to use the relay protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Jul 28, 2024
1 parent f25402e commit 20f12a5
Show file tree
Hide file tree
Showing 10 changed files with 1,488 additions and 1,151 deletions.
1,997 changes: 1,106 additions & 891 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
[package]
name = "dephy-pproxy"
version = "0.1.1"
version = "0.2.1"
edition = "2021"

[dependencies]
base64 = "0.22.1"
async-trait = "0.1.81"
clap = "4.5.4"
futures = "0.3.30"
futures-util = "0.3.30"
hex = "0.4.3"
litep2p = { git = "https://github.com/Ma233/litep2p.git", rev = "144d81c" }
# Do not upgrade multiaddr, see: https://github.com/paritytech/litep2p/pull/91
multiaddr = "0.17.1"
libp2p = { version = "0.53.2", features = ["tokio", "macros", "yamux", "noise", "tcp", "request-response"] }
prost = "0.13.1"
thiserror = "1.0.60"
tokio = { version = "1.37.0", features = ["rt-multi-thread"] }
Expand All @@ -27,3 +24,6 @@ tonic-build = "0.12.1"
[[bin]]
name = "pproxy"
path = "src/main.rs"

[dev-dependencies]
futures_ringbuf = "0.4.0"
12 changes: 2 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ pub enum Error {
TunnelIdParseError(String),
#[error("Essential task closed")]
EssentialTaskClosed,
#[error("Litep2p error: {0}")]
Litep2p(#[from] litep2p::Error),
#[error("Litep2p request response error: {0:?}")]
Litep2pRequestResponseError(litep2p::protocol::request_response::RequestResponseError),
#[error("Libp2p swarm create error: {0}")]
Libp2pSwarmCreateError(String),
#[error("Protocol not support: {0}")]
ProtocolNotSupport(String),
#[error("Unexpected response type")]
Expand Down Expand Up @@ -73,12 +71,6 @@ impl From<futures::channel::oneshot::Canceled> for Error {
}
}

impl From<litep2p::protocol::request_response::RequestResponseError> for Error {
fn from(err: litep2p::protocol::request_response::RequestResponseError) -> Self {
Error::Litep2pRequestResponseError(err)
}
}

impl From<TunnelError> for Error {
fn from(error: TunnelError) -> Self {
Error::Tunnel(error)
Expand Down
Loading

0 comments on commit 20f12a5

Please sign in to comment.