-
Notifications
You must be signed in to change notification settings - Fork 1k
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 protocol to report external address view. #566
Conversation
Should be rebased over |
protocols/observed/src/lib.rs
Outdated
type Future = Box<dyn Future<Item=(Self::Output, Self::MultiaddrFuture), Error=io::Error> + Send>; | ||
|
||
fn protocol_names(&self) -> Self::NamesIter { | ||
iter::once((Bytes::from("/observed-address/0.1.0"), ())) |
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.
Since this is "experimental", I think we should have a "non-standard" protocol name.
iter::once((Bytes::from("/observed-address/0.1.0"), ())) | |
iter::once((Bytes::from("/paritytech/observed-address/0.1.0"), ())) |
protocols/observed/src/lib.rs
Outdated
/// As `Dialer`, we get our own externally observed address. | ||
ObservedAddr(Multiaddr), | ||
/// As `Listener`, we return the underlying resource. | ||
Resource(Framed<C, UviBytes>) |
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.
This should be an object that wraps around the Framed<C, UviBytes>
and allows the user to send the multiaddress.
Address part of libp2p#443.
f8fd0f6
to
cba7101
Compare
protocols/observed/src/lib.rs
Outdated
|
||
impl<C: AsyncWrite> Sender<C> { | ||
/// Send address `a` to remote as the observed address. | ||
pub fn send_address(self, a: &Multiaddr) -> impl Future<Item=C, Error=io::Error> { |
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.
I don't think this should have a return value. We want to enforce the protocol's correct behaviour (which is to close the substream afterwards) in the API.
Also, taking ownership of the Multiaddr
removes one copy.
protocols/observed/src/lib.rs
Outdated
|
||
#[cfg(test)] | ||
mod tests { | ||
extern crate tokio_current_thread; |
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.
Since there's already a PR to replace this with tokio
(#577), I think you should do it here as well.
Test failure is unrelated ( |
…e-handled_node * upstream/master: Add protocol to report external address view. (libp2p#566) Add a TransportExt trait (libp2p#533) libp2p#399 remove tokio_current_thread tests (libp2p#577)
…e-handled_node_tasks * upstream/master: Add protocol to report external address view. (libp2p#566) Add a TransportExt trait (libp2p#533) libp2p#399 remove tokio_current_thread tests (libp2p#577)
…lection_stream * upstream/master: Add protocol to report external address view. (libp2p#566) Add a TransportExt trait (libp2p#533) libp2p#399 remove tokio_current_thread tests (libp2p#577)
…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)
Address part of #443.