Restore shuffle function

This commit is contained in:
Arnaud 2026-07-31 11:21:48 +04:00
parent 69898a02dd
commit 8f8cd2afc1
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA
2 changed files with 6 additions and 1 deletions

View File

@ -15,3 +15,8 @@ proc rand*(rng: Rng, max: Natural): int =
proc sample*[T](rng: Rng, a: openArray[T]): T =
result = a[rng.rand(a.high)]
proc shuffle*[T](rng: Rng, a: var openArray[T]) =
for i in countdown(a.high, 1):
let j = rng.rand(i)
swap(a[i], a[j])

View File

@ -12,7 +12,7 @@ import
stint, chronicles, metrics, bearssl/rand, chronos,
"."/[node, random2, spr]
from libp2p/crypto/crypto import Rng, shuffle
from libp2p/crypto/crypto import Rng
export options