mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-24 18:52:14 +00:00
swarm: Add ExpandedSwarm::is_connected (#1862)
Commit 335e55e6 removed the `ConnectionInfo` trait in favor of `PeerId`s. Commit 1bd013c8 removed `ExpandedSwarm::connection_info` as it would only return the `PeerId` that the caller is already aware of. One could use `ExpandedSwarm::connection_info` not only to retrieve the `ConnectionInfo` for a given peer, but also to check whether the underlying `Network` has a connection to the peer. This commit exposes the `is_connected` method on `Network` via `ExpandedSwarm` to check whether the `Network` has an established connection to a given peer.
This commit is contained in:
parent
d3ce35291b
commit
dae07b075b
@ -1,3 +1,8 @@
|
||||
# 0.25.1 [2020-11-26]
|
||||
|
||||
- Add `ExpandedSwarm::is_connected`.
|
||||
[PR 1862](https://github.com/libp2p/rust-libp2p/pull/1862).
|
||||
|
||||
# 0.25.0 [2020-11-25]
|
||||
|
||||
- Permit a configuration override for the substream upgrade protocol
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "libp2p-swarm"
|
||||
edition = "2018"
|
||||
description = "The libp2p swarm"
|
||||
version = "0.25.0"
|
||||
version = "0.25.1"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/libp2p/rust-libp2p"
|
||||
|
@ -463,6 +463,11 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
me.banned_peers.remove(&peer_id);
|
||||
}
|
||||
|
||||
/// Checks whether the [`Network`] has an established connection to a peer.
|
||||
pub fn is_connected(me: &Self, peer_id: &PeerId) -> bool {
|
||||
me.network.is_connected(peer_id)
|
||||
}
|
||||
|
||||
/// Returns the next event that happens in the `Swarm`.
|
||||
///
|
||||
/// Includes events from the `NetworkBehaviour` but also events about the connections status.
|
||||
|
Loading…
x
Reference in New Issue
Block a user