Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
d7c91992
Commit
d7c91992
authored
Apr 20, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1099 from ipfs/fix-randperm
core: bugfix: bootstrap random permutation
parents
b948bd65
ce791406
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
core/bootstrap.go
core/bootstrap.go
+4
-1
No files found.
core/bootstrap.go
View file @
d7c91992
...
...
@@ -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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment