Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Swarm::next_extended #1374

Merged
merged 5 commits into from
Jan 7, 2020
Merged

Add Swarm::next_extended #1374

merged 5 commits into from
Jan 7, 2020

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Jan 6, 2020

This PR is against stable-futures.
It fixes the situation with the identify test by adding a SwarmEvent struct containing more events such as "new listener address".

The Swarm now has two new async methods: next() and next_extended(). The former is the same as calling Stream::next() except that None is never returned. The latter is the same as next() except that it returns a SwarmEvent.
Additionally, polling the Swarm no longer returns a Result.

We can either merge before or after #1328, but this change should be in the CHANGELOG.

Copy link
Contributor

@romanb romanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a naming suggestion.

swarm/src/lib.rs Outdated
/// Internal function used by everything event-related.
///
/// Polls the `Swarm` for the next event.
fn poll_next_extended(mut self: Pin<&mut Self>, cx: &mut Context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn poll_next_extended(mut self: Pin<&mut Self>, cx: &mut Context)
fn poll_next_event(mut self: Pin<&mut Self>, cx: &mut Context)

swarm/src/lib.rs Outdated
/// Returns the next event that happens in the `Swarm`.
///
/// Includes events from the `NetworkBehaviour` but also events about the connections status.
pub async fn next_extended(&mut self) -> SwarmEvent<TBehaviour::OutEvent> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub async fn next_extended(&mut self) -> SwarmEvent<TBehaviour::OutEvent> {
pub async fn next_event(&mut self) -> SwarmEvent<TBehaviour::OutEvent> {

@tomaka tomaka changed the base branch from stable-futures to master January 7, 2020 09:21
@tomaka tomaka merged commit 84b6a7d into libp2p:master Jan 7, 2020
@tomaka tomaka deleted the extended-event branch January 7, 2020 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants