frostfs-node/pkg/services/audit/auditor/util.go
Pavel Karpy 923f84722a Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
2022-12-28 15:04:29 +03:00

18 lines
396 B
Go

package auditor
import (
"github.com/TrueCloudLab/frostfs-node/pkg/util/rand"
)
// nextRandUint64 returns random uint64 number [0; n) outside exclude map.
// Panics if len(exclude) >= n.
func nextRandUint64(n uint64, exclude map[uint64]struct{}) uint64 {
ln := uint64(len(exclude))
ind := rand.Uint64() % (n - ln)
for i := ind; ; i++ {
if _, ok := exclude[i]; !ok {
return i
}
}
}