mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
p2p: restore default discovery
This commit is contained in:
parent
2da18aaeae
commit
0b529e583d
1 changed files with 16 additions and 7 deletions
|
|
@ -45,12 +45,6 @@ import (
|
||||||
const (
|
const (
|
||||||
defaultDialTimeout = 15 * time.Second
|
defaultDialTimeout = 15 * time.Second
|
||||||
|
|
||||||
// This is the fairness knob for the discovery mixer. When looking for peers, we'll
|
|
||||||
// wait this long for a single source of candidates before moving on and trying other
|
|
||||||
// sources. Currently there is only one source at the Server level, so this has no effect.
|
|
||||||
// Check the fairMox tineout in the Backend for the actual timeout.
|
|
||||||
discmixTimeout = 100 * time.Millisecond
|
|
||||||
|
|
||||||
// Connectivity defaults.
|
// Connectivity defaults.
|
||||||
defaultMaxPendingPeers = 50
|
defaultMaxPendingPeers = 50
|
||||||
defaultDialRatio = 3
|
defaultDialRatio = 3
|
||||||
|
|
@ -448,7 +442,9 @@ func (srv *Server) setupLocalNode() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) setupDiscovery() error {
|
func (srv *Server) setupDiscovery() error {
|
||||||
srv.discmix = enode.NewFairMix(discmixTimeout)
|
// Set up the discovery source mixer. Here, we don't care about the
|
||||||
|
// fairness of the mix, it's just for putting the
|
||||||
|
srv.discmix = enode.NewFairMix(0)
|
||||||
|
|
||||||
// Don't listen on UDP endpoint if DHT is disabled.
|
// Don't listen on UDP endpoint if DHT is disabled.
|
||||||
if srv.NoDiscovery {
|
if srv.NoDiscovery {
|
||||||
|
|
@ -506,6 +502,19 @@ func (srv *Server) setupDiscovery() error {
|
||||||
added[proto.Name] = true
|
added[proto.Name] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up default non-protocol-specific discovery feeds if no protocol
|
||||||
|
// has configured discovery.
|
||||||
|
if len(added) == 0 {
|
||||||
|
if srv.discv4 != nil {
|
||||||
|
it := srv.discv4.RandomNodes()
|
||||||
|
srv.discmix.AddSource(enode.WithSourceName("discv4-default", it))
|
||||||
|
}
|
||||||
|
if srv.discv5 != nil {
|
||||||
|
it := srv.discv5.RandomNodes()
|
||||||
|
srv.discmix.AddSource(enode.WithSourceName("discv5-default", it))
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue