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

Resolve peers before filtering #32

Merged
merged 4 commits into from
Jun 25, 2018
Merged

Conversation

doug-perlin
Copy link
Contributor

  • make sure all the peer addresses are unified before filtering

Copy link
Contributor

@iwasaki-kenta iwasaki-kenta left a comment

Choose a reason for hiding this comment

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

Should make UnifyAddresses public and add a few more test cases.

network/utils.go Outdated

// resolves a list of addresses, ignores bad ones
func unifyAddresses(addresses []string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Best have unifyAddresses be public and have its parameter accept a variadic list over an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the function all together

t.Fatal(err)
}

testAddr := []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Best include the case for [::1], and localhost as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -79,7 +80,8 @@ func (n *Network) Listen() {

// Bootstrap with a number of peers and commence a handshake.
func (n *Network) Bootstrap(addresses ...string) {
addresses = FilterPeers(n.Host, n.Port, addresses)
resolvedAddr := unifyAddresses(addresses)
addresses = FilterPeers(n.Host, n.Port, resolvedAddr)
Copy link
Contributor

@iwasaki-kenta iwasaki-kenta Jun 25, 2018

Choose a reason for hiding this comment

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

For simplicity just have it as addresses := FilterPeers(n.Host, n.Port, UnifyAddresses(addresses)...).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the function all together

@iwasaki-kenta
Copy link
Contributor

Looks great, LGTM.

@iwasaki-kenta iwasaki-kenta merged commit d95b6b7 into master Jun 25, 2018
@iwasaki-kenta iwasaki-kenta deleted the resolvePeersBeforeFiltering branch June 25, 2018 08:27
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