Skip to content

Commit

Permalink
fix: stop using rand.Seed
Browse files Browse the repository at this point in the history
  • Loading branch information
web3-bot authored Aug 15, 2023
1 parent 0e2cc16 commit a05881d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ var (
ErrInvalidKey = errors.New("key not supported by flatfs")
)

var (
r *rand.Rand
)

func init() {
rand.Seed(time.Now().UTC().UnixNano())
r = rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
}

// Datastore implements the go-datastore Interface.
Expand Down Expand Up @@ -866,7 +870,7 @@ func folderSize(path string, deadline time.Time) (int64, initAccuracy, error) {
// randomize file order
// https://stackoverflow.com/a/42776696
for i := len(files) - 1; i > 0; i-- {
j := rand.Intn(i + 1)
j := r.Intn(i + 1)
files[i], files[j] = files[j], files[i]
}

Expand Down

0 comments on commit a05881d

Please sign in to comment.