Skip to content

Commit

Permalink
fix: add relay client to support relay transport
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Aug 14, 2024
1 parent b6904ec commit 125b499
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/p2p/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ use crate::p2p::codec::Codec;
pub(crate) struct PProxyNetworkBehaviour {
pub(crate) request_response: request_response::Behaviour<Codec>,
pub(crate) relay: relay::Behaviour,
pub(crate) relay_client: relay::client::Behaviour,
}

impl PProxyNetworkBehaviour {
pub fn new(key: &Keypair) -> Self {
pub fn new(key: &Keypair, relay_client: relay::client::Behaviour) -> Self {
let request_response = request_response::Behaviour::new(
[(
StreamProtocol::new("/pproxy/1.0.0"),
Expand All @@ -25,6 +26,7 @@ impl PProxyNetworkBehaviour {
Self {
request_response,
relay,
relay_client,
}
}
}
1 change: 1 addition & 0 deletions src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub(crate) fn new_swarm(
noise::Config::new,
yamux::Config::default,
)?
.with_relay_client(noise::Config::new, yamux::Config::default)?
.with_behaviour(PProxyNetworkBehaviour::new)?
.with_swarm_config(|c| c.with_idle_connection_timeout(std::time::Duration::from_secs(60)))
.build();
Expand Down

0 comments on commit 125b499

Please sign in to comment.