mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 11:24:31 +00:00
Avoid pulling env into blocking context
This commit is contained in:
@@ -20,6 +20,7 @@ pub fn run<'a, T: EthSpec>(
|
|||||||
mut env: Environment<T>,
|
mut env: Environment<T>,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let context = env.core_context();
|
let context = env.core_context();
|
||||||
|
let spec = context.eth2_config.spec.clone();
|
||||||
|
|
||||||
context
|
context
|
||||||
.executor
|
.executor
|
||||||
@@ -29,7 +30,7 @@ pub fn run<'a, T: EthSpec>(
|
|||||||
.block_on_dangerous(
|
.block_on_dangerous(
|
||||||
async {
|
async {
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
(validators::CMD, Some(matches)) => validators::cli_run(matches, env).await,
|
(validators::CMD, Some(matches)) => validators::cli_run(matches, &spec).await,
|
||||||
(unknown, _) => Err(format!(
|
(unknown, _) => Err(format!(
|
||||||
"{} is not a valid {} command. See --help.",
|
"{} is not a valid {} command. See --help.",
|
||||||
unknown, CMD
|
unknown, CMD
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use super::common::*;
|
use super::common::*;
|
||||||
use account_utils::{random_password_string, read_mnemonic_from_cli, read_password_from_user};
|
use account_utils::{random_password_string, read_mnemonic_from_cli, read_password_from_user};
|
||||||
use clap::{App, Arg, ArgMatches};
|
use clap::{App, Arg, ArgMatches};
|
||||||
use environment::Environment;
|
|
||||||
use eth2::{
|
use eth2::{
|
||||||
lighthouse_vc::std_types::KeystoreJsonStr,
|
lighthouse_vc::std_types::KeystoreJsonStr,
|
||||||
types::{StateId, ValidatorId},
|
types::{StateId, ValidatorId},
|
||||||
@@ -184,12 +183,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cli_run<'a, T: EthSpec>(
|
pub async fn cli_run<'a>(matches: &'a ArgMatches<'a>, spec: &ChainSpec) -> Result<(), String> {
|
||||||
matches: &'a ArgMatches<'a>,
|
|
||||||
mut env: Environment<T>,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
let spec = &env.core_context().eth2_config.spec;
|
|
||||||
|
|
||||||
let output_path: PathBuf = clap_utils::parse_required(matches, OUTPUT_PATH_FLAG)?;
|
let output_path: PathBuf = clap_utils::parse_required(matches, OUTPUT_PATH_FLAG)?;
|
||||||
|
|
||||||
if !output_path.exists() {
|
if !output_path.exists() {
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ pub mod create_validators;
|
|||||||
pub mod import_validators;
|
pub mod import_validators;
|
||||||
|
|
||||||
use clap::{App, ArgMatches};
|
use clap::{App, ArgMatches};
|
||||||
use environment::Environment;
|
use types::ChainSpec;
|
||||||
use types::EthSpec;
|
|
||||||
|
|
||||||
pub const CMD: &str = "validators";
|
pub const CMD: &str = "validators";
|
||||||
|
|
||||||
@@ -15,14 +14,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.subcommand(import_validators::cli_app())
|
.subcommand(import_validators::cli_app())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cli_run<'a, T: EthSpec>(
|
pub async fn cli_run<'a>(matches: &'a ArgMatches<'a>, spec: &ChainSpec) -> Result<(), String> {
|
||||||
matches: &'a ArgMatches<'a>,
|
|
||||||
env: Environment<T>,
|
|
||||||
) -> Result<(), String> {
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
(create_validators::CMD, Some(matches)) => {
|
(create_validators::CMD, Some(matches)) => create_validators::cli_run(matches, spec).await,
|
||||||
create_validators::cli_run::<T>(matches, env).await
|
|
||||||
}
|
|
||||||
(import_validators::CMD, Some(matches)) => import_validators::cli_run(matches).await,
|
(import_validators::CMD, Some(matches)) => import_validators::cli_run(matches).await,
|
||||||
(unknown, _) => Err(format!(
|
(unknown, _) => Err(format!(
|
||||||
"{} does not have a {} command. See --help",
|
"{} does not have a {} command. See --help",
|
||||||
|
|||||||
Reference in New Issue
Block a user