diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2014-05-18 03:37:22 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2014-05-18 03:37:22 +0000 |
commit | efb9d17c8cb83eeecf3ccaa8cc34b647aabe4af5 (patch) | |
tree | 62b12ab6d83a15382005fe132cd7861b0d7f7e53 /weighted_dist.go | |
parent | 745d414645872853fe1e3adab28dfb02f0b61dd0 (diff) |
Change the server failure close delay/discard length to be consistent.
It will vary per bridge as it is based off the DRBG, but ever attempt
at poking at any given bridge will exhibit consistent behavior.
Diffstat (limited to 'weighted_dist.go')
-rw-r--r-- | weighted_dist.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/weighted_dist.go b/weighted_dist.go index 067adaf..af0fa7d 100644 --- a/weighted_dist.go +++ b/weighted_dist.go @@ -136,6 +136,8 @@ type wDist struct { maxValue int values []int buckets []float64 + + rng *rand.Rand } // newWDist creates a weighted distribution of values ranging from min to max @@ -174,15 +176,15 @@ func (w *wDist) sample() int { func (w *wDist) reset(seed *DrbgSeed) { // Initialize the deterministic random number generator. drbg := newHashDrbg(seed) - dRng := rand.New(drbg) + w.rng = rand.New(drbg) nBuckets := (w.maxValue + 1) - w.minValue - w.values = dRng.Perm(nBuckets) + w.values = w.rng.Perm(nBuckets) w.buckets = make([]float64, nBuckets) var totalProb float64 for i, _ := range w.buckets { - prob := dRng.Float64() * (1.0 - totalProb) + prob := w.rng.Float64() * (1.0 - totalProb) w.buckets[i] = prob totalProb += prob } |