diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-11-06 05:57:57 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-11-27 17:06:12 +0800 |
commit | 9e1d9bff3b18cfa09ba96cd027fa653daae10816 (patch) | |
tree | 95d74007caa613ba0c6a62962efcda2e96b273af /p2p/discover/udp.go | |
parent | 168d0e9e45939b7282204f3f52fe86fc8110cfc7 (diff) | |
download | dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar.gz dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar.bz2 dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar.lz dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar.xz dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.tar.zst dexon-9e1d9bff3b18cfa09ba96cd027fa653daae10816.zip |
node: customizable protocol and service stacks
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r-- | p2p/discover/udp.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go index 20f69cf08..fc7fa737c 100644 --- a/p2p/discover/udp.go +++ b/p2p/discover/udp.go @@ -200,12 +200,15 @@ func ListenUDP(priv *ecdsa.PrivateKey, laddr string, natm nat.Interface, nodeDBP if err != nil { return nil, err } - tab, _ := newUDP(priv, conn, natm, nodeDBPath) + tab, _, err := newUDP(priv, conn, natm, nodeDBPath) + if err != nil { + return nil, err + } glog.V(logger.Info).Infoln("Listening,", tab.self) return tab, nil } -func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, nodeDBPath string) (*Table, *udp) { +func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, nodeDBPath string) (*Table, *udp, error) { udp := &udp{ conn: c, priv: priv, @@ -225,10 +228,15 @@ func newUDP(priv *ecdsa.PrivateKey, c conn, natm nat.Interface, nodeDBPath strin } // TODO: separate TCP port udp.ourEndpoint = makeEndpoint(realaddr, uint16(realaddr.Port)) - udp.Table = newTable(udp, PubkeyID(&priv.PublicKey), realaddr, nodeDBPath) + tab, err := newTable(udp, PubkeyID(&priv.PublicKey), realaddr, nodeDBPath) + if err != nil { + return nil, nil, err + } + udp.Table = tab + go udp.loop() go udp.readLoop() - return udp.Table, udp + return udp.Table, udp, nil } func (t *udp) close() { |