diff options
author | Zsolt Felfoldi <zsfelfoldi@gmail.com> | 2016-10-19 19:04:55 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-11-09 09:12:53 +0800 |
commit | 49da42983af7a775695166689e5bf701bcec4f81 (patch) | |
tree | 2c325a4852695697cc9616a3eac99a432711abdb /p2p/server.go | |
parent | 7db7109a5b53c339f00e9c05ac826b3dbd1f98e1 (diff) | |
download | go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar.gz go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar.bz2 go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar.lz go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar.xz go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.tar.zst go-tangerine-49da42983af7a775695166689e5bf701bcec4f81.zip |
p2p/discv5: added new topic discovery package
Diffstat (limited to 'p2p/server.go')
-rw-r--r-- | p2p/server.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/p2p/server.go b/p2p/server.go index 8e3cd93f9..649fbfb82 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/discv5" "github.com/ethereum/go-ethereum/p2p/nat" ) @@ -72,6 +73,8 @@ type Config struct { // or not. Disabling is usually useful for protocol debugging (manual topology). Discovery bool + DiscoveryV5 bool + // Name sets the node name of this server. // Use common.MakeName to create a name that follows existing conventions. Name string @@ -105,6 +108,8 @@ type Config struct { // the server is started. ListenAddr string + ListenAddrV5 string + // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the // Internet. @@ -135,6 +140,7 @@ type Server struct { listener net.Listener ourHandshake *protoHandshake lastLookup time.Time + DiscV5 *discv5.Network // These are for Peers, PeerCount (and nothing else). peerOp chan peerOpFunc @@ -352,6 +358,17 @@ func (srv *Server) Start() (err error) { srv.ntab = ntab } + if srv.DiscoveryV5 { + ntab, err := discv5.ListenUDP(srv.PrivateKey, srv.ListenAddrV5, srv.NAT, "") //srv.NodeDatabase) + if err != nil { + return err + } + if err := ntab.SetFallbackNodes(discv5.BootNodes); err != nil { + return err + } + srv.DiscV5 = ntab + } + dynPeers := (srv.MaxPeers + 1) / 2 if !srv.Discovery { dynPeers = 0 @@ -527,6 +544,9 @@ running: if srv.ntab != nil { srv.ntab.Close() } + if srv.DiscV5 != nil { + srv.DiscV5.Close() + } // Disconnect all peers. for _, p := range peers { p.Disconnect(DiscQuitting) |