aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/udp.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-12-07 19:06:49 +0800
committerFelix Lange <fjl@twurst.com>2015-12-18 06:38:54 +0800
commit04c6369a09baa5267a01713663f7c1cbb08896c9 (patch)
tree4650aaf3537e6fdab784e180f5efc9070a961cf9 /p2p/discover/udp.go
parentd1f507b7f16e359dc2773195edb72a22357e5424 (diff)
downloaddexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar.gz
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar.bz2
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar.lz
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar.xz
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.tar.zst
dexon-04c6369a09baa5267a01713663f7c1cbb08896c9.zip
p2p, p2p/discover: track bootstrap state in p2p/discover
This change simplifies the dial scheduling logic because it no longer needs to track whether the discovery table has been bootstrapped.
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r--p2p/discover/udp.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index e93949c56..72b2a45e5 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -114,13 +114,11 @@ func makeEndpoint(addr *net.UDPAddr, tcpPort uint16) rpcEndpoint {
return rpcEndpoint{IP: ip, UDP: uint16(addr.Port), TCP: tcpPort}
}
-func nodeFromRPC(rn rpcNode) (n *Node, valid bool) {
+func nodeFromRPC(rn rpcNode) (*Node, error) {
// TODO: don't accept localhost, LAN addresses from internet hosts
- // TODO: check public key is on secp256k1 curve
- if rn.IP.IsMulticast() || rn.IP.IsUnspecified() || rn.UDP == 0 {
- return nil, false
- }
- return NewNode(rn.ID, rn.IP, rn.UDP, rn.TCP), true
+ n := NewNode(rn.ID, rn.IP, rn.UDP, rn.TCP)
+ err := n.validateComplete()
+ return n, err
}
func nodeToRPC(n *Node) rpcNode {
@@ -271,7 +269,7 @@ func (t *udp) findnode(toid NodeID, toaddr *net.UDPAddr, target NodeID) ([]*Node
reply := r.(*neighbors)
for _, rn := range reply.Nodes {
nreceived++
- if n, valid := nodeFromRPC(rn); valid {
+ if n, err := nodeFromRPC(rn); err == nil {
nodes = append(nodes, n)
}
}