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
|
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user