Provide a default value for secretsDir (similar to validatorsDir)

This commit is contained in:
Zahary Karadjov 2020-06-03 14:52:36 +03:00 committed by zah
parent a75c632f7a
commit 2acda1c115
4 changed files with 24 additions and 22 deletions

View File

@ -105,11 +105,11 @@ type
abbr: "v"
name: "validator" }: seq[ValidatorKeyPath]
validatorsDir* {.
validatorsDirFlag* {.
desc: "A directory containing validator keystores."
name: "validators-dir" }: Option[InputDir]
secretsDir* {.
secretsDirFlag* {.
desc: "A directory containing validator keystore passwords."
name: "secrets-dir" }: Option[InputDir]
@ -324,8 +324,11 @@ proc defaultDataDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
func dumpDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
conf.dataDir / "dump"
func localValidatorsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
string conf.validatorsDir.get(InputDir(conf.dataDir / "validators"))
func validatorsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
string conf.validatorsDirFlag.get(InputDir(conf.dataDir / "validators"))
func secretsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
string conf.secretsDirFlag.get(InputDir(conf.dataDir / "secrets"))
func databaseDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
conf.dataDir / "db"

View File

@ -29,8 +29,7 @@ proc loadKeyStore(conf: BeaconNodeConf|ValidatorClientConf,
error "Failed to read keystore", err = err.msg, path = keystorePath
return
if conf.secretsDir.isSome:
let passphrasePath = conf.secretsDir.get / keyName
let passphrasePath = conf.secretsDir / keyName
if fileExists(passphrasePath):
let
passphrase = KeyStorePass:
@ -76,7 +75,7 @@ iterator validatorKeys*(conf: BeaconNodeConf|ValidatorClientConf): ValidatorPriv
file = validatorKeyFile.string, err = err.msg
quit 1
let validatorsDir = conf.localValidatorsDir
let validatorsDir = conf.validatorsDir
try:
for kind, file in walkDir(validatorsDir):
if kind == pcDir:

View File

@ -34,7 +34,7 @@ declareCounter beacon_blocks_proposed,
logScope: topics = "beacval"
proc saveValidatorKey*(keyName, key: string, conf: BeaconNodeConf) =
let validatorsDir = conf.localValidatorsDir
let validatorsDir = conf.validatorsDir
let outputFile = validatorsDir / keyName
createDir validatorsDir
writeFile(outputFile, key)

View File

@ -212,7 +212,7 @@ for NUM_NODE in $(seq 0 $((NUM_NODES - 1))); do
if [[ $NUM_NODE -lt $NODES_WITH_VALIDATORS ]]; then
for VALIDATOR in $(ls ${DEPOSITS_DIR} | tail -n +$(( $USER_VALIDATORS + ($VALIDATORS_PER_NODE * $NUM_NODE) + 1 )) | head -n $VALIDATORS_PER_NODE); do
cp -ar "${DEPOSITS_DIR}/$VALIDATOR" "${NODE_DATA_DIR}/validators/"
cp -a "${SECRETS_DIR}/${VALIDATOR}" "${NODE_DATA_DIR}/secrets"
cp -a "${SECRETS_DIR}/${VALIDATOR}" "${NODE_DATA_DIR}/secrets/"
done
fi