Skip to content

Commit 85f5b11

Browse files
committed
refactor: passive relay start command
1 parent 94aefc2 commit 85f5b11

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

mithril-relay/src/commands/passive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl PassiveCommand {
2323
let dial_to = self.dial_to.to_owned();
2424
let addr: Multiaddr = format!("/ip4/0.0.0.0/tcp/{}", self.listen_port).parse()?;
2525

26-
let mut relay = PassiveRelay::new(&addr).start().await?;
26+
let mut relay = PassiveRelay::start(&addr).await?;
2727
if let Some(dial_to_address) = dial_to {
2828
relay.dial_peer(dial_to_address.clone())?;
2929
}

mithril-relay/src/relay/passive.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@ pub struct PassiveRelay {
1111
}
1212

1313
impl PassiveRelay {
14-
/// Create a passive relay
15-
/// TODO: should be replaced by Self::start(...)
16-
pub fn new(addr: &Multiaddr) -> Self {
17-
Self {
18-
peer: Peer::new(addr),
19-
}
20-
}
21-
2214
/// Start a passive relay
23-
pub async fn start(self) -> StdResult<Self> {
15+
pub async fn start(addr: &Multiaddr) -> StdResult<Self> {
2416
debug!("PassiveRelay: starting...");
2517
Ok(Self {
26-
peer: self.peer.start().await?,
18+
peer: Peer::new(addr).start().await?,
2719
})
2820
}
2921

mithril-relay/tests/register_signer_signature.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@ async fn should_receive_registrations_from_signers_when_subscribed_to_pubsub() {
4848
let relay_peer_address = signer_relay.peer_address().unwrap();
4949
info!("Test: relay_address is '{relay_address:?}'");
5050

51-
let mut p2p_client1 = PassiveRelay::new(&addr)
52-
.start()
51+
let mut p2p_client1 = PassiveRelay::start(&addr)
5352
.await
5453
.expect("P2P client start failed");
5554
p2p_client1
5655
.peer
5756
.dial(relay_peer_address.clone())
5857
.expect("P2P client dial to the relay should not fail");
5958

60-
let mut p2p_client2 = PassiveRelay::new(&addr)
61-
.start()
59+
let mut p2p_client2 = PassiveRelay::start(&addr)
6260
.await
6361
.expect("P2P client start failed");
6462
p2p_client2

0 commit comments

Comments
 (0)