2020-12-23 08:56:49 +00:00
|
|
|
package auditor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/util/rand"
|
|
|
|
)
|
|
|
|
|
2022-01-11 14:07:59 +00:00
|
|
|
// nextRandUint64 returns random uint64 number [0; n) outside exclude map.
|
|
|
|
// Panics if len(exclude) >= n.
|
2020-12-23 08:56:49 +00:00
|
|
|
func nextRandUint64(n uint64, exclude map[uint64]struct{}) uint64 {
|
|
|
|
ln := uint64(len(exclude))
|
2022-01-11 14:07:59 +00:00
|
|
|
ind := rand.Uint64() % (n - ln)
|
2020-12-23 08:56:49 +00:00
|
|
|
|
2021-04-30 04:40:53 +00:00
|
|
|
for i := ind; ; i++ {
|
|
|
|
if _, ok := exclude[i]; !ok {
|
|
|
|
return i
|
2020-12-23 08:56:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|