Fix argument to be optional.

This commit is contained in:
cheatfate 2023-08-28 21:51:37 +03:00
parent 19e3c8b4e4
commit 17960d7e99
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
2 changed files with 12 additions and 9 deletions

View File

@ -163,7 +163,7 @@ type
validatorsSource* {.
desc: "Remote Web3Signer URL that will be used as a source of validators"
name: "validators-source"}: string
name: "validators-source"}: Option[string]
secretsDirFlag* {.
desc: "A directory containing validator keystore passwords"
@ -881,7 +881,7 @@ type
validatorsSource* {.
desc: "Remote Web3Signer URL that will be used as a source of validators"
name: "validators-source"}: string
name: "validators-source"}: Option[string]
secretsDirFlag* {.
desc: "A directory containing validator keystore passwords"

View File

@ -630,23 +630,26 @@ proc existsKeystore(keystoreDir: string,
proc queryValidatorsSource*(config: AnyConf): Future[seq[KeystoreData]] {.
async.} =
var keystores: seq[KeystoreData]
if len(config.validatorsSource) == 0:
if config.validatorsSource.isNone() or
len(config.validatorsSource.get()) == 0:
return keystores
let vsource = config.validatorsSource.get()
logScope:
validators_source = vsource
let
httpFlags: HttpClientFlags = {}
prestoFlags = {RestClientFlag.CommaSeparatedArray}
socketFlags = {SocketFlags.TcpNoDelay}
client =
block:
let res = RestClientRef.new(config.validatorsSource, prestoFlags,
let res = RestClientRef.new(vsource, prestoFlags,
httpFlags, socketFlags = socketFlags)
if res.isErr():
# TODO keep trying in case of temporary network failure
warn "Unable to resolve validator's source distributed signer " &
"address", remote_url = config.validatorsSource
warn "Unable to resolve validator's source distributed signer address"
return keystores
else:
res.get()
keys =
try:
@ -681,7 +684,7 @@ proc queryValidatorsSource*(config: AnyConf): Future[seq[KeystoreData]] {.
handle: FileLockHandle(opened: false),
pubkey: pubkey,
remotes: @[RemoteSignerInfo(
url: HttpHostUri(parseUri(config.validatorsSource)),
url: HttpHostUri(parseUri(vsource)),
pubkey: pubkey)],
flags: {RemoteKeystoreFlag.DynamicKeystore},
remoteType: RemoteSignerType.Web3Signer))