1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 17:03:58 +08:00

Merge pull request #1099 from ipfs/fix-randperm

core: bugfix: bootstrap random permutation
This commit is contained in:
Juan Batiz-Benet
2015-04-20 06:13:36 -07:00

View File

@ -225,8 +225,11 @@ func toPeerInfo(bp config.BootstrapPeer) peer.PeerInfo {
func randomSubsetOfPeers(in []peer.PeerInfo, max int) []peer.PeerInfo {
n := math2.IntMin(max, len(in))
var out []peer.PeerInfo
for _, val := range rand.Perm(n) {
for _, val := range rand.Perm(len(in)) {
out = append(out, in[val])
if len(out) >= n {
break
}
}
return out
}