mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Migrate validator client to clap derive (#6300)
Partially #5900 Migrate the validator client cli to clap derive
This commit is contained in:
@@ -7,6 +7,7 @@ use beacon_node_health::{
|
||||
check_node_health, BeaconNodeHealth, BeaconNodeSyncDistanceTiers, ExecutionEngineHealth,
|
||||
IsOptimistic, SyncDistanceTier,
|
||||
};
|
||||
use clap::ValueEnum;
|
||||
use environment::RuntimeContext;
|
||||
use eth2::BeaconNodeHttpClient;
|
||||
use futures::future;
|
||||
@@ -20,7 +21,8 @@ use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use strum::{EnumString, EnumVariantNames};
|
||||
use std::vec::Vec;
|
||||
use strum::EnumVariantNames;
|
||||
use tokio::{sync::RwLock, time::sleep};
|
||||
use types::{ChainSpec, Config as ConfigSpec, EthSpec, Slot};
|
||||
use validator_metrics::{inc_counter_vec, ENDPOINT_ERRORS, ENDPOINT_REQUESTS};
|
||||
@@ -727,9 +729,10 @@ async fn sort_nodes_by_health<E: EthSpec>(nodes: &mut Vec<CandidateBeaconNode<E>
|
||||
}
|
||||
|
||||
/// Serves as a cue for `BeaconNodeFallback` to tell which requests need to be broadcasted.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize, EnumString, EnumVariantNames)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize, EnumVariantNames, ValueEnum)]
|
||||
#[strum(serialize_all = "kebab-case")]
|
||||
pub enum ApiTopic {
|
||||
None,
|
||||
Attestations,
|
||||
Blocks,
|
||||
Subscriptions,
|
||||
@@ -749,7 +752,6 @@ mod tests {
|
||||
use crate::beacon_node_health::BeaconNodeHealthTier;
|
||||
use eth2::SensitiveUrl;
|
||||
use eth2::Timeouts;
|
||||
use std::str::FromStr;
|
||||
use strum::VariantNames;
|
||||
use types::{MainnetEthSpec, Slot};
|
||||
|
||||
@@ -758,10 +760,13 @@ mod tests {
|
||||
#[test]
|
||||
fn api_topic_all() {
|
||||
let all = ApiTopic::all();
|
||||
assert_eq!(all.len(), ApiTopic::VARIANTS.len());
|
||||
assert!(ApiTopic::VARIANTS
|
||||
// ignore NONE variant
|
||||
let mut variants = ApiTopic::VARIANTS.to_vec();
|
||||
variants.retain(|s| *s != "none");
|
||||
assert_eq!(all.len(), variants.len());
|
||||
assert!(variants
|
||||
.iter()
|
||||
.map(|topic| ApiTopic::from_str(topic).unwrap())
|
||||
.map(|topic| ApiTopic::from_str(topic, true).unwrap())
|
||||
.eq(all.into_iter()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user