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

p2p: preserve enode.ID type in the metered connection #17933

Merged
merged 3 commits into from
Nov 8, 2018

Conversation

kurkomisi
Copy link
Contributor

Change the type of the metered connection's id field from string to enode.ID.

@@ -253,3 +253,13 @@ func RandomID(a ID, n int) (b ID) {
}
return b
}

// Equal returns a boolean reporting whether a and b contain the same bytes.
func Equal(a, b ID) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

ID is an array type, you can just compare them with ==. Please remove this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

p2p/metrics.go Outdated
@@ -190,7 +189,7 @@ func (c *meteredConn) handshakeDone(nodeID enode.ID) {
func (c *meteredConn) Close() error {
err := c.Conn.Close()
c.lock.RLock()
if c.id == "" {
if enode.Equal(c.id, enode.ID{}) {
Copy link
Contributor

@fjl fjl Oct 17, 2018

Choose a reason for hiding this comment

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

Suggested change
if enode.Equal(c.id, enode.ID{}) {
if c.id == (enode.ID{}) {

@fjl fjl merged commit 503993c into ethereum:master Nov 8, 2018
@karalabe karalabe added this to the 1.8.18 milestone Nov 8, 2018
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.

3 participants