mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-19 19:09:08 +00:00
reduce ProveField
warnings in conf.nim
(#5485)
Address some verbose `ProveField` warnings and `XCannotRaiseY` hints in `conf.nim`.
This commit is contained in:
parent
dd1f362536
commit
0cca65904d
@ -1111,16 +1111,22 @@ func dumpDirOutgoing*(config: AnyConf): string =
|
|||||||
config.dumpDir / "outgoing" # things we produced
|
config.dumpDir / "outgoing" # things we produced
|
||||||
|
|
||||||
proc createDumpDirs*(config: BeaconNodeConf) =
|
proc createDumpDirs*(config: BeaconNodeConf) =
|
||||||
if config.dumpEnabled:
|
proc fail {.noreturn.} =
|
||||||
if (let res = secureCreatePath(config.dumpDirInvalid); res.isErr):
|
raiseAssert "createDumpDirs should be used only in the right context"
|
||||||
warn "Could not create dump directory",
|
|
||||||
path = config.dumpDirInvalid, err = ioErrorMsg(res.error)
|
case config.cmd
|
||||||
if (let res = secureCreatePath(config.dumpDirIncoming); res.isErr):
|
of BNStartUpCmd.noCommand:
|
||||||
warn "Could not create dump directory",
|
if config.dumpEnabled:
|
||||||
path = config.dumpDirIncoming, err = ioErrorMsg(res.error)
|
if (let res = secureCreatePath(config.dumpDirInvalid); res.isErr):
|
||||||
if (let res = secureCreatePath(config.dumpDirOutgoing); res.isErr):
|
warn "Could not create dump directory",
|
||||||
warn "Could not create dump directory",
|
path = config.dumpDirInvalid, err = ioErrorMsg(res.error)
|
||||||
path = config.dumpDirOutgoing, err = ioErrorMsg(res.error)
|
if (let res = secureCreatePath(config.dumpDirIncoming); res.isErr):
|
||||||
|
warn "Could not create dump directory",
|
||||||
|
path = config.dumpDirIncoming, err = ioErrorMsg(res.error)
|
||||||
|
if (let res = secureCreatePath(config.dumpDirOutgoing); res.isErr):
|
||||||
|
warn "Could not create dump directory",
|
||||||
|
path = config.dumpDirOutgoing, err = ioErrorMsg(res.error)
|
||||||
|
else: fail()
|
||||||
|
|
||||||
func parseCmdArg*(T: type Eth2Digest, input: string): T
|
func parseCmdArg*(T: type Eth2Digest, input: string): T
|
||||||
{.raises: [ValueError].} =
|
{.raises: [ValueError].} =
|
||||||
@ -1230,6 +1236,7 @@ func eraDir*(config: BeaconNodeConf): string =
|
|||||||
# The era directory should be shared between networks of the same type..
|
# The era directory should be shared between networks of the same type..
|
||||||
string config.eraDirFlag.get(InputDir(config.dataDir / "era"))
|
string config.eraDirFlag.get(InputDir(config.dataDir / "era"))
|
||||||
|
|
||||||
|
{.push warning[ProveField]:off.} # https://github.com/nim-lang/Nim/issues/22791
|
||||||
func outWalletName*(config: BeaconNodeConf): Option[WalletName] =
|
func outWalletName*(config: BeaconNodeConf): Option[WalletName] =
|
||||||
proc fail {.noreturn.} =
|
proc fail {.noreturn.} =
|
||||||
raiseAssert "outWalletName should be used only in the right context"
|
raiseAssert "outWalletName should be used only in the right context"
|
||||||
@ -1246,10 +1253,12 @@ func outWalletName*(config: BeaconNodeConf): Option[WalletName] =
|
|||||||
else: fail()
|
else: fail()
|
||||||
else:
|
else:
|
||||||
fail()
|
fail()
|
||||||
|
{.pop.}
|
||||||
|
|
||||||
|
{.push warning[ProveField]:off.} # https://github.com/nim-lang/Nim/issues/22791
|
||||||
func outWalletFile*(config: BeaconNodeConf): Option[OutFile] =
|
func outWalletFile*(config: BeaconNodeConf): Option[OutFile] =
|
||||||
proc fail {.noreturn.} =
|
proc fail {.noreturn.} =
|
||||||
raiseAssert "outWalletName should be used only in the right context"
|
raiseAssert "outWalletFile should be used only in the right context"
|
||||||
|
|
||||||
case config.cmd
|
case config.cmd
|
||||||
of wallets:
|
of wallets:
|
||||||
@ -1263,6 +1272,7 @@ func outWalletFile*(config: BeaconNodeConf): Option[OutFile] =
|
|||||||
else: fail()
|
else: fail()
|
||||||
else:
|
else:
|
||||||
fail()
|
fail()
|
||||||
|
{.pop.}
|
||||||
|
|
||||||
func databaseDir*(dataDir: OutDir): string =
|
func databaseDir*(dataDir: OutDir): string =
|
||||||
dataDir / "db"
|
dataDir / "db"
|
||||||
@ -1271,7 +1281,11 @@ template databaseDir*(config: AnyConf): string =
|
|||||||
config.dataDir.databaseDir
|
config.dataDir.databaseDir
|
||||||
|
|
||||||
func runAsService*(config: BeaconNodeConf): bool =
|
func runAsService*(config: BeaconNodeConf): bool =
|
||||||
config.cmd == noCommand and config.runAsServiceFlag
|
case config.cmd
|
||||||
|
of noCommand:
|
||||||
|
config.runAsServiceFlag
|
||||||
|
else:
|
||||||
|
false
|
||||||
|
|
||||||
template writeValue*(writer: var JsonWriter,
|
template writeValue*(writer: var JsonWriter,
|
||||||
value: TypedInputFile|InputFile|InputDir|OutPath|OutDir|OutFile) =
|
value: TypedInputFile|InputFile|InputDir|OutPath|OutDir|OutFile) =
|
||||||
@ -1295,7 +1309,7 @@ proc readValue*(r: var TomlReader, value: var GraffitiBytes)
|
|||||||
r.raiseUnexpectedValue("A printable string or 0x-prefixed hex-encoded raw bytes expected")
|
r.raiseUnexpectedValue("A printable string or 0x-prefixed hex-encoded raw bytes expected")
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, val: var NatConfig)
|
proc readValue*(r: var TomlReader, val: var NatConfig)
|
||||||
{.raises: [IOError, SerializationError].} =
|
{.raises: [SerializationError].} =
|
||||||
val = try: parseCmdArg(NatConfig, r.readValue(string))
|
val = try: parseCmdArg(NatConfig, r.readValue(string))
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
raise newException(SerializationError, err.msg)
|
raise newException(SerializationError, err.msg)
|
||||||
@ -1308,7 +1322,7 @@ proc readValue*(r: var TomlReader, a: var Eth2Digest)
|
|||||||
r.raiseUnexpectedValue("Hex string expected")
|
r.raiseUnexpectedValue("Hex string expected")
|
||||||
|
|
||||||
proc readValue*(reader: var TomlReader, value: var ValidatorPubKey)
|
proc readValue*(reader: var TomlReader, value: var ValidatorPubKey)
|
||||||
{.raises: [IOError, SerializationError].} =
|
{.raises: [SerializationError].} =
|
||||||
let keyAsString = try:
|
let keyAsString = try:
|
||||||
reader.readValue(string)
|
reader.readValue(string)
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
@ -1322,21 +1336,21 @@ proc readValue*(reader: var TomlReader, value: var ValidatorPubKey)
|
|||||||
raiseUnexpectedValue(reader, "Valid hex-encoded public key expected")
|
raiseUnexpectedValue(reader, "Valid hex-encoded public key expected")
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, a: var PubKey0x)
|
proc readValue*(r: var TomlReader, a: var PubKey0x)
|
||||||
{.raises: [IOError, SerializationError].} =
|
{.raises: [SerializationError].} =
|
||||||
try:
|
try:
|
||||||
a = parseCmdArg(PubKey0x, r.readValue(string))
|
a = parseCmdArg(PubKey0x, r.readValue(string))
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
r.raiseUnexpectedValue("a 0x-prefixed hex-encoded string expected")
|
r.raiseUnexpectedValue("a 0x-prefixed hex-encoded string expected")
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, a: var WalletName)
|
proc readValue*(r: var TomlReader, a: var WalletName)
|
||||||
{.raises: [IOError, SerializationError].} =
|
{.raises: [SerializationError].} =
|
||||||
try:
|
try:
|
||||||
a = parseCmdArg(WalletName, r.readValue(string))
|
a = parseCmdArg(WalletName, r.readValue(string))
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
r.raiseUnexpectedValue("string expected")
|
r.raiseUnexpectedValue("string expected")
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, a: var Address)
|
proc readValue*(r: var TomlReader, a: var Address)
|
||||||
{.raises: [IOError, SerializationError].} =
|
{.raises: [SerializationError].} =
|
||||||
try:
|
try:
|
||||||
a = parseCmdArg(Address, r.readValue(string))
|
a = parseCmdArg(Address, r.readValue(string))
|
||||||
except CatchableError:
|
except CatchableError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user