diff --git a/src/p2p/behaviour/mod.rs b/src/p2p/behaviour/mod.rs index f1dde56b..7c4ee823 100644 --- a/src/p2p/behaviour/mod.rs +++ b/src/p2p/behaviour/mod.rs @@ -37,7 +37,7 @@ where autonat: AutoNat, } -async fn poll_swarm(mut swarm: Swarm>) -> Result<(), ()> +async fn poll_swarm(_swarm: Swarm>) -> Result<(), ()> where KS: RecordStore + Send + 'static, { diff --git a/src/p2p/relay.rs b/src/p2p/relay.rs index 409c0d22..b86c4700 100644 --- a/src/p2p/relay.rs +++ b/src/p2p/relay.rs @@ -54,6 +54,7 @@ enum Message { GetAddresses(oneshot::Sender>), ListenOn(Vec, oneshot::Sender>), Dial(Multiaddr, oneshot::Sender>), + GetConnectedPeers(oneshot::Sender>), } impl RelayNode { @@ -82,6 +83,12 @@ impl RelayNode { self.sender.send(Message::Dial(addr, s)).await?; r.await? } + + pub async fn connected_peers(&mut self) -> Result, Error> { + let (s, r) = oneshot::channel(); + self.sender.send(Message::GetConnectedPeers(s)).await?; + Ok(r.await?) + } } #[derive(Debug)] @@ -235,6 +242,9 @@ async fn poll_swarm( swarm.dial(addr)?; s.send(Ok(())).map_err(|_| SwarmError::SendError)? } + Message::GetConnectedPeers(s) => s + .send(swarm.connected_peers().map(|p| p.to_owned()).collect()) + .map_err(|_| SwarmError::SendError)?, }, Either::Right((Some(_), _)) => { // process swarm event