提交 ce791406 作者: Juan Batiz-Benet

core: bugfix: bootstrap random permutation

the random permutaton for bootstrap peers was not working as
intended, returning the first four bootstrap peers always.
this commit fixes it to be a random subset.
上级 b948bd65
......@@ -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
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论