This commit is contained in:
Dan Laine 2020-06-23 16:54:03 -04:00
parent 6c6136d551
commit 8ce7bda92a
1 changed files with 2 additions and 8 deletions

View File

@ -93,17 +93,11 @@ func (s *set) set(vdrs []Validator) {
newCap = lenVdrs
}
s.vdrSlice = make([]Validator, 0, newCap)
} else {
s.vdrSlice = s.vdrSlice[:0]
}
if cap(s.sampler.Weights) > len(s.sampler.Weights)*maxExcessCapacityFactor {
newCap := cap(s.sampler.Weights) / capacityReductionFactor
if newCap < lenVdrs {
newCap = lenVdrs
}
s.sampler.Weights = make([]uint64, 0, newCap)
} else {
s.vdrSlice = s.vdrSlice[:0]
s.sampler.Weights = s.sampler.Weights[:0]
}
s.vdrMap = make(map[[20]byte]int, lenVdrs)