diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-24 23:04:41 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-24 23:04:41 +0800 |
commit | 8646365b42ddae30e596835b4512792ca11196a5 (patch) | |
tree | 03977b5bf677fa2a7e57953fba28c0aa21da6a88 /p2p/discover/udp.go | |
parent | 6def110c37d4d43402c4b658ce6b291400f840e5 (diff) | |
download | dexon-8646365b42ddae30e596835b4512792ca11196a5.tar dexon-8646365b42ddae30e596835b4512792ca11196a5.tar.gz dexon-8646365b42ddae30e596835b4512792ca11196a5.tar.bz2 dexon-8646365b42ddae30e596835b4512792ca11196a5.tar.lz dexon-8646365b42ddae30e596835b4512792ca11196a5.tar.xz dexon-8646365b42ddae30e596835b4512792ca11196a5.tar.zst dexon-8646365b42ddae30e596835b4512792ca11196a5.zip |
cmd/bootnode, eth, p2p, p2p/discover: use a fancier db design
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r-- | p2p/discover/udp.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go index 6805fb686..65741b5f5 100644 --- a/p2p/discover/udp.go +++ b/p2p/discover/udp.go @@ -144,7 +144,7 @@ type reply struct { } // ListenUDP returns a new table that listens for UDP packets on laddr. -func ListenUDP(priv *ecdsa.PrivateKey, laddr string, natm nat.Interface, seeder *Cache) (*Table, error) { +func ListenUDP(priv *ecdsa.PrivateKey, laddr string, natm nat.Interface, nodeDBPath string) (*Table, error) { addr, err := net.ResolveUDPAddr("udp", laddr) if err != nil { return nil, err @@ -153,12 +153,12 @@ func ListenUDP(priv *ecdsa.PrivateKey, laddr string, natm nat.Interface, seeder if err != nil { return nil, err } - tab, _ := newUDP(priv, conn, natm, seeder) + tab, _ := newUDP(priv, conn, natm, nodeDBPath) glog.V(logger.Info).Infoln("Listening,", tab.self) return tab, nil } -func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, seeder *Cache) (*Table, *udp) { +func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, nodeDBPath string) (*Table, *udp) { udp := &udp{ conn: c, priv: priv, @@ -176,7 +176,7 @@ func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, seeder *Cache) ( realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port} } } - udp.Table = newTable(udp, PubkeyID(&priv.PublicKey), realaddr, seeder) + udp.Table = newTable(udp, PubkeyID(&priv.PublicKey), realaddr, nodeDBPath) go udp.loop() go udp.readLoop() return udp.Table, udp @@ -449,7 +449,7 @@ func (req *findnode) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte if expired(req.Expiration) { return errExpired } - if t.cache.get(fromID) == nil { + if t.db.node(fromID) == nil { // No bond exists, we don't process the packet. This prevents // an attack vector where the discovery protocol could be used // to amplify traffic in a DDOS attack. A malicious actor |