nimbus-eth2/beacon_chain/conf.nim

42 lines
1.2 KiB
Nim
Raw Normal View History

import
2018-12-08 14:17:47 +00:00
confutils/defs, spec/crypto, milagro_crypto, randao
type
ValidatorKeyPath* = distinct string
2018-11-29 01:08:34 +00:00
BeaconNodeConf* = object
dataDir* {.
desc: "The directory where nimbus will store all blockchain data.",
shorthand: "d",
defaultValue: getConfigDir() / "nimbus".}: DirPath
bootstrapNodes* {.
desc: "Specifies one or more bootstrap nodes to use when connecting to the network.",
shorthand: "b".}: seq[string]
tcpPort* {.
desc: "TCP listening port".}: int
udpPort* {.
desc: "UDP listening port".}: int
validatorKeys* {.
desc: "A path to a pair of public and private keys for a validator. " &
"Nimbus will automatically add the extensions .privkey and .pubkey.",
shorthand: "v".}: seq[ValidatorKeyPath]
2018-12-09 08:25:02 +00:00
proc readFileBytes(path: string): seq[byte] =
cast[seq[byte]](readFile(path))
2018-12-05 13:58:41 +00:00
proc loadPrivKey*(p: ValidatorKeyPath): ValidatorPrivKey =
2018-12-09 08:25:02 +00:00
initSigKey(readFileBytes(string(p) & ".privkey"))
2018-12-05 13:58:41 +00:00
2018-12-08 14:17:47 +00:00
proc loadRandao*(p: ValidatorKeyPath): Randao =
2018-12-09 08:25:02 +00:00
initRandao(readFileBytes(string(p) & ".randao"))
2018-12-05 13:58:41 +00:00
2018-12-08 14:17:47 +00:00
proc parse*(T: type ValidatorKeyPath, input: TaintedString): T =
result = T(input)
discard loadPrivKey(result)
discard loadRandao(result)
2018-11-29 01:08:34 +00:00