aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-12-15 00:40:49 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-12-15 00:40:49 +0800
commit2573094df2b3f2fad03ce465694f24e9899a31e4 (patch)
tree7f3b1a83dd531944d82ccd243ef5a51cf63f6f4a /p2p
parent745026b7b4fbbb3036a3d456a26db35fac4e3374 (diff)
downloaddexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar.gz
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar.bz2
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar.lz
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar.xz
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.tar.zst
dexon-2573094df2b3f2fad03ce465694f24e9899a31e4.zip
p2p/discover, p2p/discv5: use flexible comparison for IPs
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/udp_test.go2
-rw-r--r--p2p/discv5/net.go2
-rw-r--r--p2p/discv5/node.go3
-rw-r--r--p2p/discv5/udp.go2
4 files changed, 4 insertions, 5 deletions
diff --git a/p2p/discover/udp_test.go b/p2p/discover/udp_test.go
index 53cfac6f9..8bca37ffe 100644
--- a/p2p/discover/udp_test.go
+++ b/p2p/discover/udp_test.go
@@ -374,7 +374,7 @@ func TestUDP_successfulPing(t *testing.T) {
if n.ID != rid {
t.Errorf("node has wrong ID: got %v, want %v", n.ID, rid)
}
- if !bytes.Equal(n.IP, test.remoteaddr.IP) {
+ if !n.IP.Equal(test.remoteaddr.IP) {
t.Errorf("node has wrong IP: got %v, want: %v", n.IP, test.remoteaddr.IP)
}
if int(n.UDP) != test.remoteaddr.Port {
diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go
index 1348c6774..74d485836 100644
--- a/p2p/discv5/net.go
+++ b/p2p/discv5/net.go
@@ -759,7 +759,7 @@ func (net *Network) internNodeFromNeighbours(sender *net.UDPAddr, rn rpcNode) (n
}
return n, err
}
- if !bytes.Equal(n.IP, rn.IP) || n.UDP != rn.UDP || n.TCP != rn.TCP {
+ if !n.IP.Equal(rn.IP) || n.UDP != rn.UDP || n.TCP != rn.TCP {
err = fmt.Errorf("metadata mismatch: got %v, want %v", rn, n)
}
return n, err
diff --git a/p2p/discv5/node.go b/p2p/discv5/node.go
index b6b6f149d..b2025ebcb 100644
--- a/p2p/discv5/node.go
+++ b/p2p/discv5/node.go
@@ -17,7 +17,6 @@
package discv5
import (
- "bytes"
"crypto/ecdsa"
"crypto/elliptic"
"encoding/hex"
@@ -81,7 +80,7 @@ func (n *Node) addrEqual(a *net.UDPAddr) bool {
if ipv4 := a.IP.To4(); ipv4 != nil {
ip = ipv4
}
- return n.UDP == uint16(a.Port) && bytes.Equal(n.IP, ip)
+ return n.UDP == uint16(a.Port) && n.IP.Equal(ip)
}
// Incomplete returns true for nodes with no IP address.
diff --git a/p2p/discv5/udp.go b/p2p/discv5/udp.go
index a6114e032..b43f6d198 100644
--- a/p2p/discv5/udp.go
+++ b/p2p/discv5/udp.go
@@ -196,7 +196,7 @@ func makeEndpoint(addr *net.UDPAddr, tcpPort uint16) rpcEndpoint {
}
func (e1 rpcEndpoint) equal(e2 rpcEndpoint) bool {
- return e1.UDP == e2.UDP && e1.TCP == e2.TCP && bytes.Equal(e1.IP, e2.IP)
+ return e1.UDP == e2.UDP && e1.TCP == e2.TCP && e1.IP.Equal(e2.IP)
}
func nodeFromRPC(sender *net.UDPAddr, rn rpcNode) (*Node, error) {