-
Notifications
You must be signed in to change notification settings - Fork 211
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
Conversation
doug-perlin
commented
Jun 25, 2018
- make sure all the peer addresses are unified before filtering
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.
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 { |
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.
Best have unifyAddresses
be public and have its parameter accept a variadic list over an array.
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.
removed the function all together
network/utils_test.go
Outdated
t.Fatal(err) | ||
} | ||
|
||
testAddr := []string{ |
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.
Best include the case for [::1]
, and localhost
as well.
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.
added
network/network.go
Outdated
@@ -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) |
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.
For simplicity just have it as addresses := FilterPeers(n.Host, n.Port, UnifyAddresses(addresses)...)
.
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.
removed the function all together
Looks great, LGTM. |