Only limit the number of nodes returned by network resolver.

This commit is contained in:
Milos Gajdos 2019-10-08 15:48:52 +01:00
parent 61800fb7d7
commit fe5846603a
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

View File

@ -171,9 +171,16 @@ func (n *network) resolveNodes() ([]string, error) {
// collect network node addresses // collect network node addresses
var nodes []string var nodes []string
i := 0
for _, record := range records { for _, record := range records {
nodes = append(nodes, record.Address) nodes = append(nodes, record.Address)
nodeMap[record.Address] = true nodeMap[record.Address] = true
i++
// break once MaxConnection nodes has been reached
if i == MaxConnections {
break
}
} }
// use the dns resolver to expand peers // use the dns resolver to expand peers
@ -195,15 +202,6 @@ func (n *network) resolveNodes() ([]string, error) {
} }
} }
// only return MaxConnections nodes
if len(nodes) > MaxConnections {
resNodes := make([]string, MaxConnections)
for i, _ := range resNodes {
resNodes[i] = nodes[i]
}
return resNodes, nil
}
return nodes, nil return nodes, nil
} }