Skip to content

Commit

Permalink
Rename BeaconNodeClient -> BeaconNodeHttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Sep 23, 2020
1 parent f14e58b commit 2e1d657
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use beacon_chain::{
};
use discv5::enr::{CombinedKey, EnrBuilder};
use environment::null_logger;
use eth2::{types::*, BeaconNodeClient, Url};
use eth2::{types::*, BeaconNodeHttpClient, Url};
use eth2_libp2p::{rpc::methods::MetaData, types::EnrBitfield, NetworkGlobals};
use http_api::{Config, Context};
use network::NetworkMessage;
Expand Down Expand Up @@ -43,7 +43,7 @@ const SKIPPED_SLOTS: &[u64] = &[

struct ApiTester {
chain: Arc<BeaconChain<BlockingMigratorEphemeralHarnessType<E>>>,
client: BeaconNodeClient,
client: BeaconNodeHttpClient,
next_block: SignedBeaconBlock<E>,
attestations: Vec<Attestation<E>>,
attester_slashing: AttesterSlashing<E>,
Expand Down Expand Up @@ -167,7 +167,7 @@ impl ApiTester {

tokio::spawn(async { server.await });

let client = BeaconNodeClient::new(
let client = BeaconNodeHttpClient::new(
Url::parse(&format!(
"http://{}:{}",
listening_socket.ip(),
Expand Down
4 changes: 2 additions & 2 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ impl fmt::Display for Error {
/// A wrapper around `reqwest::Client` which provides convenience methods for interfacing with a
/// Lighthouse Beacon Node HTTP server (`http_api`).
#[derive(Clone)]
pub struct BeaconNodeClient {
pub struct BeaconNodeHttpClient {
client: reqwest::Client,
server: Url,
}

impl BeaconNodeClient {
impl BeaconNodeHttpClient {
/// Returns `Err(())` if the URL is invalid.
pub fn new(server: Url) -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions common/eth2/src/lighthouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::{
types::{Epoch, EthSpec, GenericResponse, ValidatorId},
BeaconNodeClient, Error,
BeaconNodeHttpClient, Error,
};
use proto_array::core::ProtoArray;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Health {
}
}

impl BeaconNodeClient {
impl BeaconNodeHttpClient {
/// `GET lighthouse/health`
pub async fn get_lighthouse_health(&self) -> Result<GenericResponse<Health>, Error> {
let mut path = self.server.clone();
Expand Down
6 changes: 3 additions & 3 deletions testing/node_test_rig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use beacon_node::ProductionBeaconNode;
use environment::RuntimeContext;
use eth2::{
reqwest::{ClientBuilder, Url},
BeaconNodeClient,
BeaconNodeHttpClient,
};
use std::path::PathBuf;
use std::time::Duration;
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<E: EthSpec> LocalBeaconNode<E> {
impl<E: EthSpec> LocalBeaconNode<E> {
/// Returns a `RemoteBeaconNode` that can connect to `self`. Useful for testing the node as if
/// it were external this process.
pub fn remote_node(&self) -> Result<BeaconNodeClient, String> {
pub fn remote_node(&self) -> Result<BeaconNodeHttpClient, String> {
let listen_addr = self
.client
.http_api_listen_addr()
Expand All @@ -73,7 +73,7 @@ impl<E: EthSpec> LocalBeaconNode<E> {
.timeout(HTTP_TIMEOUT)
.build()
.map_err(|e| format!("Unable to build HTTP client: {:?}", e))?;
Ok(BeaconNodeClient::from_components(
Ok(BeaconNodeHttpClient::from_components(
beacon_node_url,
beacon_node_http_client,
))
Expand Down
4 changes: 2 additions & 2 deletions testing/simulator/src/local_network.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use node_test_rig::{
environment::RuntimeContext,
eth2::{types::StateId, BeaconNodeClient},
eth2::{types::StateId, BeaconNodeHttpClient},
ClientConfig, LocalBeaconNode, LocalValidatorClient, ValidatorConfig, ValidatorFiles,
};
use parking_lot::RwLock;
Expand Down Expand Up @@ -141,7 +141,7 @@ impl<E: EthSpec> LocalNetwork<E> {
}

/// For all beacon nodes in `Self`, return a HTTP client to access each nodes HTTP API.
pub fn remote_nodes(&self) -> Result<Vec<BeaconNodeClient>, String> {
pub fn remote_nodes(&self) -> Result<Vec<BeaconNodeHttpClient>, String> {
let beacon_nodes = self.beacon_nodes.read();

beacon_nodes
Expand Down
8 changes: 4 additions & 4 deletions validator_client/src/attestation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
validator_store::ValidatorStore,
};
use environment::RuntimeContext;
use eth2::BeaconNodeClient;
use eth2::BeaconNodeHttpClient;
use futures::StreamExt;
use slog::{crit, error, info, trace};
use slot_clock::SlotClock;
Expand All @@ -22,7 +22,7 @@ pub struct AttestationServiceBuilder<T, E: EthSpec> {
duties_service: Option<DutiesService<T, E>>,
validator_store: Option<ValidatorStore<T, E>>,
slot_clock: Option<T>,
beacon_node: Option<BeaconNodeClient>,
beacon_node: Option<BeaconNodeHttpClient>,
context: Option<RuntimeContext<E>>,
}

Expand Down Expand Up @@ -52,7 +52,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationServiceBuilder<T, E> {
self
}

pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self {
pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self {
self.beacon_node = Some(beacon_node);
self
}
Expand Down Expand Up @@ -90,7 +90,7 @@ pub struct Inner<T, E: EthSpec> {
duties_service: DutiesService<T, E>,
validator_store: ValidatorStore<T, E>,
slot_clock: T,
beacon_node: BeaconNodeClient,
beacon_node: BeaconNodeHttpClient,
context: RuntimeContext<E>,
}

Expand Down
8 changes: 4 additions & 4 deletions validator_client/src/block_service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::validator_store::ValidatorStore;
use environment::RuntimeContext;
use eth2::{types::Graffiti, BeaconNodeClient};
use eth2::{types::Graffiti, BeaconNodeHttpClient};
use futures::channel::mpsc::Receiver;
use futures::{StreamExt, TryFutureExt};
use slog::{crit, debug, error, info, trace, warn};
Expand All @@ -13,7 +13,7 @@ use types::{EthSpec, PublicKey, Slot};
pub struct BlockServiceBuilder<T, E: EthSpec> {
validator_store: Option<ValidatorStore<T, E>>,
slot_clock: Option<Arc<T>>,
beacon_node: Option<BeaconNodeClient>,
beacon_node: Option<BeaconNodeHttpClient>,
context: Option<RuntimeContext<E>>,
graffiti: Option<Graffiti>,
}
Expand All @@ -39,7 +39,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockServiceBuilder<T, E> {
self
}

pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self {
pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self {
self.beacon_node = Some(beacon_node);
self
}
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockServiceBuilder<T, E> {
pub struct Inner<T, E: EthSpec> {
validator_store: ValidatorStore<T, E>,
slot_clock: Arc<T>,
beacon_node: BeaconNodeClient,
beacon_node: BeaconNodeHttpClient,
context: RuntimeContext<E>,
graffiti: Option<Graffiti>,
}
Expand Down
8 changes: 4 additions & 4 deletions validator_client/src/duties_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
validator_store::ValidatorStore,
};
use environment::RuntimeContext;
use eth2::BeaconNodeClient;
use eth2::BeaconNodeHttpClient;
use futures::channel::mpsc::Sender;
use futures::{SinkExt, StreamExt};
use parking_lot::RwLock;
Expand Down Expand Up @@ -315,7 +315,7 @@ impl DutiesStore {
pub struct DutiesServiceBuilder<T, E: EthSpec> {
validator_store: Option<ValidatorStore<T, E>>,
slot_clock: Option<T>,
beacon_node: Option<BeaconNodeClient>,
beacon_node: Option<BeaconNodeHttpClient>,
context: Option<RuntimeContext<E>>,
allow_unsynced_beacon_node: bool,
}
Expand All @@ -341,7 +341,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesServiceBuilder<T, E> {
self
}

pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self {
pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self {
self.beacon_node = Some(beacon_node);
self
}
Expand Down Expand Up @@ -384,7 +384,7 @@ pub struct Inner<T, E: EthSpec> {
store: Arc<DutiesStore>,
validator_store: ValidatorStore<T, E>,
pub(crate) slot_clock: T,
pub(crate) beacon_node: BeaconNodeClient,
pub(crate) beacon_node: BeaconNodeHttpClient,
context: RuntimeContext<E>,
/// If true, the duties service will poll for duties from the beacon node even if it is not
/// synced.
Expand Down
8 changes: 4 additions & 4 deletions validator_client/src/fork_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use environment::RuntimeContext;
use eth2::{types::StateId, BeaconNodeClient};
use eth2::{types::StateId, BeaconNodeHttpClient};
use futures::StreamExt;
use parking_lot::RwLock;
use slog::{debug, trace};
Expand All @@ -16,7 +16,7 @@ const TIME_DELAY_FROM_SLOT: Duration = Duration::from_millis(80);
pub struct ForkServiceBuilder<T, E: EthSpec> {
fork: Option<Fork>,
slot_clock: Option<T>,
beacon_node: Option<BeaconNodeClient>,
beacon_node: Option<BeaconNodeHttpClient>,
context: Option<RuntimeContext<E>>,
}

Expand All @@ -35,7 +35,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkServiceBuilder<T, E> {
self
}

pub fn beacon_node(mut self, beacon_node: BeaconNodeClient) -> Self {
pub fn beacon_node(mut self, beacon_node: BeaconNodeHttpClient) -> Self {
self.beacon_node = Some(beacon_node);
self
}
Expand Down Expand Up @@ -66,7 +66,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkServiceBuilder<T, E> {
/// Helper to minimise `Arc` usage.
pub struct Inner<T, E: EthSpec> {
fork: RwLock<Option<Fork>>,
beacon_node: BeaconNodeClient,
beacon_node: BeaconNodeHttpClient,
context: RuntimeContext<E>,
slot_clock: T,
}
Expand Down
4 changes: 2 additions & 2 deletions validator_client/src/is_synced.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eth2::BeaconNodeClient;
use eth2::BeaconNodeHttpClient;
use slog::{debug, error, warn, Logger};
use slot_clock::SlotClock;

Expand All @@ -16,7 +16,7 @@ const SYNC_TOLERANCE: u64 = 4;
/// The second condition means the even if the beacon node thinks that it's syncing, we'll still
/// try to use it if it's close enough to the head.
pub async fn is_synced<T: SlotClock>(
beacon_node: &BeaconNodeClient,
beacon_node: &BeaconNodeHttpClient,
slot_clock: &T,
log_opt: Option<&Logger>,
) -> bool {
Expand Down
8 changes: 4 additions & 4 deletions validator_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use block_service::{BlockService, BlockServiceBuilder};
use clap::ArgMatches;
use duties_service::{DutiesService, DutiesServiceBuilder};
use environment::RuntimeContext;
use eth2::{reqwest::ClientBuilder, BeaconNodeClient, StatusCode, Url};
use eth2::{reqwest::ClientBuilder, BeaconNodeHttpClient, StatusCode, Url};
use fork_service::{ForkService, ForkServiceBuilder};
use futures::channel::mpsc;
use initialized_validators::InitializedValidators;
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
.build()
.map_err(|e| format!("Unable to build HTTP client: {:?}", e))?;
let beacon_node =
BeaconNodeClient::from_components(beacon_node_url, beacon_node_http_client);
BeaconNodeHttpClient::from_components(beacon_node_url, beacon_node_http_client);

// Perform some potentially long-running initialization tasks.
let (yaml_config, genesis_time, genesis_validators_root) = tokio::select! {
Expand Down Expand Up @@ -235,7 +235,7 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
}

async fn init_from_beacon_node<E: EthSpec>(
beacon_node: &BeaconNodeClient,
beacon_node: &BeaconNodeHttpClient,
context: &RuntimeContext<E>,
) -> Result<(YamlConfig, u64, Hash256), String> {
// Wait for the beacon node to come online.
Expand Down Expand Up @@ -305,7 +305,7 @@ async fn init_from_beacon_node<E: EthSpec>(

/// Request the version from the node, looping back and trying again on failure. Exit once the node
/// has been contacted.
async fn wait_for_node(beacon_node: &BeaconNodeClient, log: &Logger) -> Result<(), String> {
async fn wait_for_node(beacon_node: &BeaconNodeHttpClient, log: &Logger) -> Result<(), String> {
// Try to get the version string from the node, looping until success is returned.
loop {
let log = log.clone();
Expand Down
4 changes: 2 additions & 2 deletions validator_client/src/validator_duty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use eth2::{
types::{BeaconCommitteeSubscription, StateId, ValidatorId},
BeaconNodeClient,
BeaconNodeHttpClient,
};
use serde::{Deserialize, Serialize};
use types::{CommitteeIndex, Epoch, PublicKey, PublicKeyBytes, Slot};
Expand Down Expand Up @@ -50,7 +50,7 @@ impl ValidatorDuty {
///
/// Will only request proposer duties if `current_epoch == request_epoch`.
pub async fn download(
beacon_node: &BeaconNodeClient,
beacon_node: &BeaconNodeHttpClient,
current_epoch: Epoch,
request_epoch: Epoch,
pubkey: PublicKey,
Expand Down

0 comments on commit 2e1d657

Please sign in to comment.