-
Notifications
You must be signed in to change notification settings - Fork 1.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
basichost: allow overriding Addrs() #196
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.
👍 on the approach. Doesnt feel like cheating to me. Get some tests up in there and lets do it :)
p2p/host/basic/basic_host.go
Outdated
@@ -23,6 +23,8 @@ var log = logging.Logger("basichost") | |||
|
|||
var NegotiateTimeout = time.Second * 60 | |||
|
|||
type AddrsFactory func([]ma.Multiaddr) []ma.Multiaddr |
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.
Document this type please. Why it is here? What is it used for and maybe a practical example of how it can be used.
p2p/host/basic/basic_host.go
Outdated
@@ -23,6 +23,8 @@ var log = logging.Logger("basichost") | |||
|
|||
var NegotiateTimeout = time.Second * 60 | |||
|
|||
type AddrsFactory func([]ma.Multiaddr) []ma.Multiaddr | |||
|
|||
// Option is a type used to pass in options to the host. |
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.
great opportunity to also improve Option documentations :)
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 have a bit of work-in-progress code to refactor construction of BasicHost and Swarm, the Option type will be gone afterwards. Separate PR 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.
I counted and there's at least 4 different ways of passing in various options to host and swarm, including global variables :) -- it's in bad need of an options struct.
4067302
to
6cbb939
Compare
Okay here we go |
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.
LGTM
This is for ipfs/kubo#3613. I decided to cheat and just sidestep the whole passing-options-through-n-layers-of-node-initialization. The calling code will simply pass a closure as the
AddrsFactory
option which applies the announced/noAnnounced addrs if neccessary.(I'm open to better names than AddrsFactory.)
TODO: