Update src/mix_protocol.nim

- Simplify with valueOr

Co-authored-by: richΛrd <info@richardramos.me>
This commit is contained in:
AkshayaMani
2025-01-30 09:50:42 -05:00
committed by GitHub
parent 1ed184b1b3
commit 40b7b494db

View File

@@ -195,12 +195,9 @@ proc anonymizeLocalProtocolSend*(
if i == L - 1:
randPeerId = destPeerId
else:
let cryptoRandomIntResult = cryptoRandomInt(availableIndices.len)
if cryptoRandomIntResult.isErr:
let randomIndexPosition = cryptoRandomInt(availableIndices.len).valueOr:
error "Failed to generate random number", err = cryptoRandomIntResult.error
return
let
randomIndexPosition = cryptoRandomIntResult.value
selectedIndex = availableIndices[randomIndexPosition]
randPeerId = pubNodeInfoKeys[selectedIndex]
availableIndices.del(randomIndexPosition)