-
Notifications
You must be signed in to change notification settings - Fork 996
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
Conversation
There was a problem hiding this 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.
core/src/nodes/listeners.rs
Outdated
/// 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…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)
…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)
…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)
I would consider
listeners.rs
as final or almost final, so let's add documentation to it.