-
Notifications
You must be signed in to change notification settings - Fork 1.1k
RoutedHost: NewStream ensures we have the means to connect to the peer #208
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
Conversation
p2p/host/routed/routed.go
Outdated
} | ||
rh.Peerstore().AddAddrs(p, addrs, pstore.TempAddrTTL) | ||
} | ||
|
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 there any reason to not just call Connect
? We'll end up calling Connect
on the host again from within NewStream
but that should be a no-op.
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 think we can safely use connect too, although it's redundant once we've put the addresses in the Peerstore.
Note that BasicHost doesn't call connect explicitly; instead the connection is established by Dial
when it sees that it has no active connections.
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 5 lines -vs- 3 when using Connect, so I am opting for it; needs a good comment though.
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.
Updated to use Connect; so yeah, both shorter and easier to understand with the right comment.
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 is a great catch, thanks @vyzo 👍
This drops the opensensus dependency. Nobody uses this, from what I can tell. fixes #58
Fixes #207