diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-11 10:49:55 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-12-11 10:49:55 +0100 |
commit | a31b67035996a7fe050f7920e39e4ea016fb1842 (patch) | |
tree | 61b4fb8c51fedce8e0d469135c43314e846d0b1d /lib | |
parent | 45cd97c4923b287715737ee6d3595e0c5177bf44 (diff) |
Add GossipReactor::is_connected_to() helper fn for checking whether a client is connected to another client
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/reactor/gossip/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/src/reactor/gossip/mod.rs b/lib/src/reactor/gossip/mod.rs index 809ccb0..bf8b4eb 100644 --- a/lib/src/reactor/gossip/mod.rs +++ b/lib/src/reactor/gossip/mod.rs @@ -117,6 +117,21 @@ impl GossipReactor { self.inner.profile().read().await.client().connect(addr).await } + #[cfg(test)] + async fn is_connected_to(&self, addr: ipfs::MultiaddrWithPeerId) -> Result<bool> { + self.inner + .profile() + .read() + .await + .client() + .ipfs + .peers() + .await + .map(|connections| { + connections.iter().any(|connection| connection.addr == addr) + }) + } + async fn handle_gossip_message(&self, msg: Arc<ipfs::PubsubMessage>) -> Result<()> { use std::convert::TryFrom; |