helios/examples/discovery.rs

32 lines
904 B
Rust
Raw Normal View History

2023-03-03 09:05:35 +00:00
use std::path::PathBuf;
use env_logger::Env;
use eyre::Result;
use helios::{config::networks::Network, prelude::*};
use consensus::p2p::P2pNetworkInterface;
#[tokio::main]
async fn main() -> Result<()> {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
2023-03-03 09:05:35 +00:00
let untrusted_rpc_url = "https://eth-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>";
log::info!("Using untrusted RPC URL [REDACTED]");
let consensus_rpc = "https://www.lightclientdata.org";
log::info!("Using consensus RPC URL: {}", consensus_rpc);
let mut client: Client<FileDB, P2pNetworkInterface> = ClientBuilder::new()
.network(Network::MAINNET)
.consensus_rpc(consensus_rpc)
.execution_rpc(untrusted_rpc_url)
.load_external_fallback()
.data_dir(PathBuf::from("/tmp/helios"))
.build()
.await?;
client.start().await?;
Ok(())
}