From 64ba3c076b87e0e67637db21c1c6b5a3edaec993 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Thu, 6 Aug 2020 10:40:28 +0800 Subject: [PATCH] Revert "Use Less Intensive Search" (#6899) * Revert "Use Less Intensive Search (#6848)" This reverts commit 69e0e302b3af3383cb856ca04ab9723fb652ad26. --- beacon-chain/p2p/BUILD.bazel | 1 - beacon-chain/p2p/discovery.go | 5 +---- beacon-chain/p2p/service_test.go | 4 ---- beacon-chain/p2p/subnets.go | 8 +------- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 08df649e8..0501e0008 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -47,7 +47,6 @@ go_library( "//shared/featureconfig:go_default_library", "//shared/hashutil:go_default_library", "//shared/iputils:go_default_library", - "//shared/mathutil:go_default_library", "//shared/p2putils:go_default_library", "//shared/params:go_default_library", "//shared/roughtime:go_default_library", diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index 4e1396121..bab2f8bca 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -31,7 +31,6 @@ type Listener interface { Ping(*enode.Node) error RequestENR(*enode.Node) (*enode.Node, error) LocalNode() *enode.LocalNode - AllNodes() []*enode.Node } // RefreshENR uses an epoch to refresh the enr entry for our node @@ -144,10 +143,8 @@ func (s *Service) createListener( } } dv5Cfg := discover.Config{ - PrivateKey: privKey, - ValidSchemes: enode.ValidSchemes, + PrivateKey: privKey, } - dv5Cfg.Bootnodes = []*enode.Node{} for _, addr := range s.cfg.Discv5BootStrapAddr { bootNode, err := enode.Parse(enode.ValidSchemes, addr) diff --git a/beacon-chain/p2p/service_test.go b/beacon-chain/p2p/service_test.go index 27936c6cf..93b423873 100644 --- a/beacon-chain/p2p/service_test.go +++ b/beacon-chain/p2p/service_test.go @@ -25,10 +25,6 @@ import ( type mockListener struct{} -func (mockListener) AllNodes() []*enode.Node { - panic("implement me") -} - func (mockListener) Self() *enode.Node { panic("implement me") } diff --git a/beacon-chain/p2p/subnets.go b/beacon-chain/p2p/subnets.go index d866b2d7d..81a16e45d 100644 --- a/beacon-chain/p2p/subnets.go +++ b/beacon-chain/p2p/subnets.go @@ -6,7 +6,6 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/prysmaticlabs/go-bitfield" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" - "github.com/prysmaticlabs/prysm/shared/mathutil" "github.com/prysmaticlabs/prysm/shared/params" ) @@ -23,12 +22,7 @@ func (s *Service) FindPeersWithSubnet(index uint64) (bool, error) { return false, nil } iterator := s.dv5Listener.RandomNodes() - - // Select appropriate size for search. - maxSize := uint64(len(s.dv5Listener.AllNodes())) - min := int(mathutil.Min(maxSize, lookupLimit)) - - nodes := enode.ReadNodes(iterator, min) + nodes := enode.ReadNodes(iterator, lookupLimit) exists := false for _, node := range nodes { if node.IP() == nil {