Skip to content

Commit

Permalink
swarm: Expose currently connected peers (#2378)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Inden <[email protected]>
  • Loading branch information
dvc94ch and mxinden authored Dec 13, 2021
1 parent ab7b5a4 commit 939e296
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

- Move `swarm::Toggle` to `swarm::behaviour::Toggle` (see [PR 2375]).

- Add `Swarm::connected_peers` (see [PR 2378]).

- Implement `swarm::NetworkBehaviour` on `either::Either` (see [PR 2370]).

[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
[PR 2350]: https://github.com/libp2p/rust-libp2p/pull/2350
[PR 2362]: https://github.com/libp2p/rust-libp2p/pull/2362
[PR 2370]: https://github.com/libp2p/rust-libp2p/pull/2370
[PR 2375]: https://github.com/libp2p/rust-libp2p/pull/2375
[PR 2378]: https://github.com/libp2p/rust-libp2p/pull/2378

# 0.32.0 [2021-11-16]

Expand Down
5 changes: 5 additions & 0 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,11 @@ where
self.network.is_connected(peer_id)
}

/// Returns the currently connected peers.
pub fn connected_peers(&self) -> impl Iterator<Item = &PeerId> {
self.network.connected_peers()
}

/// Returns a reference to the provided [`NetworkBehaviour`].
pub fn behaviour(&self) -> &TBehaviour {
&self.behaviour
Expand Down

0 comments on commit 939e296

Please sign in to comment.