Lookup Bootnode instead of Random Nodes (#3555)

* add workspace change

* change to lookup bootnode
This commit is contained in:
Nishant Das 2019-09-23 10:17:11 +05:30 committed by GitHub
parent b7853f1fa8
commit 71098b6ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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():