Skip to content

Commit

Permalink
better logging for relay configuration in boost
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed Oct 2, 2023
1 parent 4989e57 commit 326baeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
16 changes: 12 additions & 4 deletions mev-boost-rs/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use serde::Deserialize;
use std::{future::Future, net::Ipv4Addr, pin::Pin, task::Poll};
use tokio::task::{JoinError, JoinHandle};
use url::Url;
use tracing::info;

#[derive(Debug, Deserialize)]
pub struct Config {
Expand Down Expand Up @@ -60,16 +61,23 @@ impl Service {
pub fn from(config: Config) -> Self {
let relays = parse_relay_endpoints(&config.relays);

if relays.is_empty() {
tracing::error!("no valid relays provided; please restart with correct configuration");
}

Self { host: config.host, port: config.port, relays, network: config.network }
}

/// Spawns a new [`RelayMux`] and [`BlindedBlockProviderServer`] task
pub fn spawn(self, context: Option<Context>) -> Result<ServiceHandle, Error> {
let Self { host, port, relays, network } = self;

if relays.is_empty() {
tracing::error!("no valid relays provided; please restart with correct configuration");
} else {
let count = relays.len();
info!("configured with {count} relays");
for relay in &relays {
info!(?relay, "configured with relay");
}
}

let context =
if let Some(context) = context { context } else { Context::try_from(&network)? };
let relays = relays.into_iter().map(Relay::from);
Expand Down
9 changes: 8 additions & 1 deletion mev-rs/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ethereum_consensus::{
use std::{fmt, ops::Deref};
use url::Url;

#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct RelayEndpoint {
url: Url,
public_key: BlsPublicKey,
Expand All @@ -29,6 +29,13 @@ impl TryFrom<Url> for RelayEndpoint {
}
}

impl fmt::Debug for RelayEndpoint {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{0}", self.url)
}
}


#[derive(Clone)]
pub struct Relay {
provider: BlockProvider,
Expand Down

0 comments on commit 326baeb

Please sign in to comment.