diff --git a/rapide/rapide.go b/rapide/rapide.go index 9043e2dfd..6d76a9254 100644 --- a/rapide/rapide.go +++ b/rapide/rapide.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - mrand "math/rand" "sync" "sync/atomic" @@ -51,9 +50,8 @@ func (c *Client) Get(ctx context.Context, root cid.Cid, traversal ipsl.Traversal errors: make([]error, len(c.ServerDrivenDownloaders)), } - seedRand := mrand.New(mrand.NewSource(mrand.Int63())) for i, sdd := range c.ServerDrivenDownloaders { - d.startServerDrivenWorker(ctx, sdd, &d.root, &d.errors[i], seedRand.Int63()^int64(i)) + d.startServerDrivenWorker(ctx, sdd, &d.root, &d.errors[i]) } return out diff --git a/rapide/serverdriven.go b/rapide/serverdriven.go index ca4d2cec7..9ee3ee766 100644 --- a/rapide/serverdriven.go +++ b/rapide/serverdriven.go @@ -18,19 +18,17 @@ type serverDrivenWorker struct { outErr *error current *node tasks map[cid.Cid]*node - rand mrand.Rand // TODO: add a dontGoThere map which tells you what part of the dag this node is not able to handle } -func (d *download) startServerDrivenWorker(ctx context.Context, impl ServerDrivenDownloader, root *node, outErr *error, seed int64) { +func (d *download) startServerDrivenWorker(ctx context.Context, impl ServerDrivenDownloader, root *node, outErr *error) { w := &serverDrivenWorker{ impl: impl, download: d, outErr: outErr, current: root, tasks: make(map[cid.Cid]*node), - rand: *mrand.New(mrand.NewSource(seed)), } go w.work(ctx) @@ -224,9 +222,9 @@ func (w *serverDrivenWorker) compareChildWithMinimums(child *node, minWorkers ui // if scores are identical randomly select other nodes to randomly distribute where downloads are placed if luck == 0 { // lazy initialisation of luck, this allows to creating a random value when better values exists back to back - luck = uint(w.rand.Int()) + luck = uint(mrand.Int()) } - newLuck := uint(w.rand.Int()) + newLuck := uint(mrand.Int()) if newLuck >= luck { break }