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

basichost: allow overriding Addrs() #196

Merged
merged 1 commit into from
May 31, 2017
Merged

Conversation

ghost
Copy link

@ghost ghost commented May 29, 2017

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:

  • tests

@ghost ghost requested review from hsanjuan, whyrusleeping and Kubuxu May 29, 2017 13:08
@ghost ghost added the status/in-progress In progress label May 29, 2017
Copy link
Contributor

@whyrusleeping whyrusleeping left a 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 :)

@@ -23,6 +23,8 @@ var log = logging.Logger("basichost")

var NegotiateTimeout = time.Second * 60

type AddrsFactory func([]ma.Multiaddr) []ma.Multiaddr
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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 :)

Copy link
Author

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 :)

Copy link
Author

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.

@ghost ghost force-pushed the feat/addresses-announce branch from 4067302 to 6cbb939 Compare May 30, 2017 18:39
@ghost
Copy link
Author

ghost commented May 30, 2017

Okay here we go

Copy link
Contributor

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

LGTM

@whyrusleeping whyrusleeping merged commit 78dabda into master May 31, 2017
@whyrusleeping whyrusleeping deleted the feat/addresses-announce branch May 31, 2017 00:12
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.

2 participants