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 some documentation to listeners stream #547

Merged
merged 4 commits into from
Oct 15, 2018

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Oct 9, 2018

I would consider listeners.rs as final or almost final, so let's add documentation to it.

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

A few questions, mostly for my education.

/// a `Transport` that supports the protocols you wish you listen on.
///
/// Then, call `ListenerStream::listen_on` as many times as you want to start the actual act of
/// listening.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would I want to call listen_on multiple times? I.e. is there a use case where this is necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, to listen on multiple different addresses.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, then I'd suggest: "Then, call ListenersStream::listen_on for all addresses you want to start listening on."

/// println!("A connection has arrived on {}", listen_addr);
/// // We don't do anything with the newly-opened connection, but in a real-life
/// // program you probably want to use it!
/// drop(upgrade);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to call drop here? I.e. should we tell users to explicitly drop connections they don't want to handle?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not necessary, it's to make it consistent with the comment just above.

Copy link
Contributor

Choose a reason for hiding this comment

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

For n00b users it kind of looks like I have to call drop to dispose of it. Maybe just remove it to avoid misunderstandings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, this is more about Rust than about libp2p, and Rust beginners are not supposed to use the ListenersStream directly.

@twittner twittner merged commit e179951 into libp2p:master Oct 15, 2018
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Oct 16, 2018
…e-handled_node

* upstream/master:
  Remove the old API (libp2p#565)
  Change some `nat_traversal`s to consider a prefix. (libp2p#550)
  Add some documentation to listeners stream (libp2p#547)
  Add shutdown functionality to `NodeStream`. (libp2p#560)
  Shut down yamux and fix mplex shutdown. (libp2p#559)
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Oct 17, 2018
…e-handled_node_tasks

* dp/chore/test-core-handled_node:
  Fix broken test
  Clarify the behaviour of is_shutting_down
  Fixes broken test after upstream changes
  Remove the old API (libp2p#565)
  Change some `nat_traversal`s to consider a prefix. (libp2p#550)
  Add some documentation to listeners stream (libp2p#547)
  Add shutdown functionality to `NodeStream`. (libp2p#560)
  Shut down yamux and fix mplex shutdown. (libp2p#559)
dvdplm added a commit to dvdplm/rust-libp2p that referenced this pull request Nov 1, 2018
…ref-debug-impl

* upstream/master:
  Use paritytech/rust-secp256k1 (libp2p#598)
  Use websocket 0.21.0 (libp2p#597)
  Reexport multihash from the facade (libp2p#587)
  Add substrate to the list of projects using libp2p (libp2p#595)
  Remove spaces before semicolons (libp2p#591)
  Add protocol to report external address view. (libp2p#566)
  Add a TransportExt trait (libp2p#533)
  libp2p#399 remove tokio_current_thread tests (libp2p#577)
  Remove even more unused files (libp2p#581)
  Fix the polling process in handled node (libp2p#582)
  Fix panicking when Kad responder is destroyed (libp2p#575)
  Remove other unused files (libp2p#570)
  Fix panic in raw swarm (libp2p#571)
  Remove two unused files (libp2p#567)
  New core (libp2p#568)
  Remove the old API (libp2p#565)
  Change some `nat_traversal`s to consider a prefix. (libp2p#550)
  Add some documentation to listeners stream (libp2p#547)
  Add shutdown functionality to `NodeStream`. (libp2p#560)
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.

3 participants