mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 14:22:13 +00:00
removed rng
This commit is contained in:
parent
84555eb240
commit
7bf2357908
4
dht.go
4
dht.go
@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -65,8 +64,6 @@ type IpfsDHT struct {
|
||||
providers *providers.ProviderManager
|
||||
|
||||
birth time.Time // When this peer started up
|
||||
rng *rand.Rand // Source of randomness
|
||||
rnglk sync.Mutex // Rand does not support concurrency
|
||||
|
||||
Validator record.Validator
|
||||
|
||||
@ -222,7 +219,6 @@ func makeDHT(ctx context.Context, h host.Host, cfg config) (*IpfsDHT, error) {
|
||||
host: h,
|
||||
strmap: make(map[peer.ID]*messageSender),
|
||||
birth: time.Now(),
|
||||
rng: rand.New(rand.NewSource(rand.Int63())),
|
||||
protocols: protocols,
|
||||
serverProtocols: serverProtocols,
|
||||
bucketSize: cfg.bucketSize,
|
||||
|
6
query.go
6
query.go
@ -136,12 +136,6 @@ func (dht *IpfsDHT) runQuery(ctx context.Context, target string, queryFn queryFn
|
||||
return nil, kb.ErrLookupFailure
|
||||
}
|
||||
|
||||
dht.rnglk.Lock()
|
||||
dht.rng.Shuffle(len(seedPeers), func(i, j int) {
|
||||
seedPeers[i], seedPeers[j] = seedPeers[j], seedPeers[i]
|
||||
})
|
||||
dht.rnglk.Unlock()
|
||||
|
||||
q := &query{
|
||||
ctx: queryCtx,
|
||||
cancel: cancelQuery,
|
||||
|
Loading…
x
Reference in New Issue
Block a user