From 71098b6ed8ad0376a4c58eec42c86a4fd2383190 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Mon, 23 Sep 2019 10:17:11 +0530 Subject: [PATCH] Lookup Bootnode instead of Random Nodes (#3555) * add workspace change * change to lookup bootnode --- beacon-chain/p2p/discovery.go | 2 +- beacon-chain/p2p/service.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index 4f79d4fe0..b9f4987eb 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -97,7 +97,7 @@ func convertToMultiAddr(nodes []*enode.Node) []ma.Multiaddr { func convertToSingleMultiAddr(node *enode.Node) (ma.Multiaddr, error) { ip4 := node.IP().To4() if ip4 == nil { - return nil, errors.New("node doesn't have an ip4 address") + return nil, errors.Errorf("node doesn't have an ip4 address, it's stated IP is %s", node.IP().String()) } pubkey := node.Pubkey() assertedKey := convertToInterfacePubkey(pubkey) diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index 42017bcb1..bcd62daff 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -190,10 +190,14 @@ func (s *Service) Disconnect(pid peer.ID) error { // listen for new nodes watches for new nodes in the network and adds them to the peerstore. func (s *Service) listenForNewNodes() { ticker := time.NewTicker(pollingPeriod) + bootNode, err := enode.Parse(enode.ValidSchemes, s.cfg.BootstrapNodeAddr) + if err != nil { + log.Fatal(err) + } for { select { case <-ticker.C: - nodes := s.dv5Listener.LookupRandom() + nodes := s.dv5Listener.Lookup(bootNode.ID()) multiAddresses := convertToMultiAddr(nodes) s.connectWithAllPeers(multiAddresses) case <-s.ctx.Done():