From 0b529e583dadaf57c2bd59ce74a44c3a49cf7a69 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 5 Jun 2025 11:15:22 +0200 Subject: [PATCH] p2p: restore default discovery --- p2p/server.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/p2p/server.go b/p2p/server.go index da3495a1f6..1f859089af 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -45,12 +45,6 @@ import ( const ( 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. defaultMaxPendingPeers = 50 defaultDialRatio = 3 @@ -448,7 +442,9 @@ func (srv *Server) setupLocalNode() 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. if srv.NoDiscovery { @@ -506,6 +502,19 @@ func (srv *Server) setupDiscovery() error { 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 }