mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
Only limit the number of nodes returned by network resolver.
This commit is contained in:
parent
61800fb7d7
commit
fe5846603a
@ -171,9 +171,16 @@ func (n *network) resolveNodes() ([]string, error) {
|
||||
|
||||
// collect network node addresses
|
||||
var nodes []string
|
||||
|
||||
i := 0
|
||||
for _, record := range records {
|
||||
nodes = append(nodes, record.Address)
|
||||
nodeMap[record.Address] = true
|
||||
i++
|
||||
// break once MaxConnection nodes has been reached
|
||||
if i == MaxConnections {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user