mirror of
https://github.com/logos-storage/logos-storage-nim-dht.git
synced 2026-08-03 13:13:22 +00:00
Restore shuffle function
This commit is contained in:
parent
69898a02dd
commit
8f8cd2afc1
@ -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])
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user