From 1d704411574c3ed7ec927b0876a0d24d3ffba78a Mon Sep 17 00:00:00 2001 From: Mac L Date: Fri, 3 Nov 2023 13:22:32 +1100 Subject: [PATCH] Add suggestions --- Cargo.lock | 1 + common/eth2/Cargo.toml | 1 + common/eth2/src/lib.rs | 11 ++++------- validator_client/src/lib.rs | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af9d0a0ad8..6b60c58c24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2099,6 +2099,7 @@ version = "0.1.0" dependencies = [ "account_utils", "bytes", + "derivative", "eth2_keystore", "ethereum_serde_utils", "ethereum_ssz", diff --git a/common/eth2/Cargo.toml b/common/eth2/Cargo.toml index 02460551a9..027136ac01 100644 --- a/common/eth2/Cargo.toml +++ b/common/eth2/Cargo.toml @@ -31,6 +31,7 @@ slashing_protection = { workspace = true } mediatype = "0.19.13" mime = "0.3.16" pretty_reqwest_error = { workspace = true } +derivative = { workspace = true } [dev-dependencies] tokio = { workspace = true } diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index 9df1f2f600..ca244fd89c 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -16,6 +16,7 @@ pub mod types; use self::mixin::{RequestAccept, ResponseOptional}; use self::types::{Error as ResponseError, *}; +use derivative::Derivative; use futures::Stream; use futures_util::StreamExt; use lighthouse_network::PeerId; @@ -143,19 +144,15 @@ impl Timeouts { /// A wrapper around `reqwest::Client` which provides convenience methods for interfacing with a /// Lighthouse Beacon Node HTTP server (`http_api`). -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Derivative)] +#[derivative(PartialEq)] pub struct BeaconNodeHttpClient { + #[derivative(PartialEq = "ignore")] client: reqwest::Client, server: SensitiveUrl, timeouts: Timeouts, } -impl PartialEq for BeaconNodeHttpClient { - fn eq(&self, other: &Self) -> bool { - self.server == other.server && self.timeouts == other.timeouts - } -} - impl Eq for BeaconNodeHttpClient {} impl fmt::Display for BeaconNodeHttpClient { diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index 8212841dbb..b45e5ad1ef 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -342,15 +342,15 @@ impl ProductionValidatorClient { let candidates = beacon_nodes .into_iter() - .zip(0..num_nodes) - .map(|(node, id)| CandidateBeaconNode::new(node, id)) + .enumerate() + .map(|(id, node)| CandidateBeaconNode::new(node, id)) .collect(); let proposer_nodes_num = proposer_nodes.len(); let proposer_candidates = proposer_nodes .into_iter() - .zip(0..num_nodes) - .map(|(node, id)| CandidateBeaconNode::new(node, id)) + .enumerate() + .map(|(id, node)| CandidateBeaconNode::new(node, id)) .collect(); // Set the count for beacon node fallbacks excluding the primary beacon node.