Skip to content

Commit

Permalink
use utils/rand to shuffle identity list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed May 17, 2023
1 parent b7d2185 commit bdb5330
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/bootstrap/cmd/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/onflow/flow-go/model/flow/assignment"
"github.com/onflow/flow-go/model/flow/factory"
"github.com/onflow/flow-go/model/flow/filter"
"github.com/onflow/flow-go/utils/rand"
)

// Construct cluster assignment with internal and partner nodes uniformly
Expand All @@ -28,11 +29,11 @@ func constructClusterAssignment(partnerNodes, internalNodes []model.NodeInfo) (f

// shuffle both collector lists based on a non-deterministic algorithm
var err error
partners, err = partners.Shuffle()
err = rand.Shuffle(uint(len(partners)), func(i, j uint) { partners[i], partners[j] = partners[j], partners[i] })
if err != nil {
log.Fatal().Err(err).Msg("could not shuffle partners")
}
internals, err = internals.Shuffle()
err = rand.Shuffle(uint(len(internals)), func(i, j uint) { internals[i], internals[j] = internals[j], internals[i] })
if err != nil {
log.Fatal().Err(err).Msg("could not shuffle internals")
}
Expand Down

0 comments on commit bdb5330

Please sign in to comment.