chore(chat2): selection of store node at random (#1118)

* chore(chat2): selection of store node at random

* fix(chat2): random number overflow fix
This commit is contained in:
Aaryamann Challani 2022-09-06 16:57:55 +05:30 committed by GitHub
parent 3f7aa8c6e4
commit 135b7209dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -6,7 +6,7 @@ when not(compileOption("threads")):
{.push raises: [Defect].}
import std/[tables, strformat, strutils, times, json, options]
import std/[tables, strformat, strutils, times, json, options, random]
import confutils, chronicles, chronos, stew/shims/net as stewNet,
eth/keys, bearssl, stew/[byteutils, endians2, results],
nimcrypto/pbkdf2
@ -456,7 +456,7 @@ proc processInput(rfd: AsyncFD, rng: ref BrHmacDrbgContext) {.async.} =
storenode = some(parseRemotePeerInfo(conf.storenode))
elif discoveredNodes.len > 0:
echo "Store enabled, but no store nodes configured. Choosing one at random from discovered peers"
storenode = some(discoveredNodes[0])
storenode = some(discoveredNodes[rand(0..len(discoveredNodes) - 1)])
if storenode.isSome():
# We have a viable storenode. Let's query it for historical messages.