MCPcopy Create free account
hub / github.com/Commit-Boost/commit-boost-client / load_from_env

Method load_from_env

crates/common/src/signer/loader.rs:59–94  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

57 }
58
59 pub fn load_from_env(self) -> eyre::Result<Vec<ConsensusSigner>> {
60 Ok(match self {
61 SignerLoader::File { key_path } => {
62 let path = load_env_var(SIGNER_KEYS_ENV).map(PathBuf::from).unwrap_or(key_path);
63 let file = std::fs::read_to_string(path)
64 .unwrap_or_else(|_| panic!("Unable to find keys file"));
65
66 let keys: Vec<FileKey> = serde_json::from_str(&file)?;
67
68 keys.into_iter()
69 .map(|k| ConsensusSigner::new_from_bytes(&k.secret_key))
70 .collect::<Result<_, _>>()
71 .context("failed to load signers")?
72 }
73 SignerLoader::ValidatorsDir { keys_path, secrets_path, format } => {
74 // TODO: hacky way to load for now, we should support reading the
75 // definitions.yml file
76 let keys_path =
77 load_env_var(SIGNER_DIR_KEYS_ENV).map(PathBuf::from).unwrap_or(keys_path);
78 let secrets_path =
79 load_env_var(SIGNER_DIR_SECRETS_ENV).map(PathBuf::from).unwrap_or(secrets_path);
80
81 return match format {
82 ValidatorKeysFormat::Lighthouse => {
83 load_from_lighthouse_format(keys_path, secrets_path)
84 }
85 ValidatorKeysFormat::Teku => load_from_teku_format(keys_path, secrets_path),
86 ValidatorKeysFormat::Lodestar => {
87 load_from_lodestar_format(keys_path, secrets_path)
88 }
89 ValidatorKeysFormat::Prysm => load_from_prysm_format(keys_path, secrets_path),
90 ValidatorKeysFormat::Nimbus => load_from_nimbus_format(keys_path, secrets_path),
91 };
92 }
93 })
94 }
95}
96
97pub struct FileKey {

Callers 1

load_keysMethod · 0.45

Calls 6

load_env_varFunction · 0.85
load_from_teku_formatFunction · 0.85
load_from_prysm_formatFunction · 0.85
load_from_nimbus_formatFunction · 0.85

Tested by

no test coverage detected