2022-12-02 23:41:50 +00:00
|
|
|
use eyre::Result;
|
|
|
|
|
|
|
|
// From helios::config
|
|
|
|
use config::{checkpoints, networks};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
// Construct the checkpoint fallback services.
|
|
|
|
// The `build` method will fetch a list of [CheckpointFallbackService]s from a community-mainained list by ethPandaOps.
|
|
|
|
// This list is NOT guaranteed to be secure, but is provided in good faith.
|
|
|
|
// The raw list can be found here: https://github.com/ethpandaops/checkpoint-sync-health-checks/blob/master/_data/endpoints.yaml
|
|
|
|
let cf = checkpoints::CheckpointFallback::new()
|
|
|
|
.build()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// Fetch the latest goerli checkpoint
|
|
|
|
let goerli_checkpoint = cf
|
|
|
|
.fetch_latest_checkpoint(&networks::Network::GOERLI)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-12-04 20:28:44 +00:00
|
|
|
println!("Fetched latest goerli checkpoint: {goerli_checkpoint}");
|
2022-12-02 23:41:50 +00:00
|
|
|
|
|
|
|
// Fetch the latest mainnet checkpoint
|
|
|
|
let mainnet_checkpoint = cf
|
|
|
|
.fetch_latest_checkpoint(&networks::Network::MAINNET)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-12-04 20:28:44 +00:00
|
|
|
println!("Fetched latest mainnet checkpoint: {mainnet_checkpoint}");
|
2022-12-02 23:41:50 +00:00
|
|
|
|
|
|
|
// Let's get a list of all the fallback service endpoints for mainnet
|
|
|
|
let endpoints = cf.get_all_fallback_endpoints(&networks::Network::MAINNET);
|
2022-12-04 20:28:44 +00:00
|
|
|
println!("Fetched all mainnet fallback endpoints: {endpoints:?}");
|
2022-12-02 23:41:50 +00:00
|
|
|
|
|
|
|
// Since we built the checkpoint fallback services, we can also just get the raw checkpoint fallback services.
|
|
|
|
// The `get_fallback_services` method returns a reference to the internal list of CheckpointFallbackService objects
|
|
|
|
// for the given network.
|
|
|
|
let services = cf.get_fallback_services(&networks::Network::MAINNET);
|
2022-12-04 20:28:44 +00:00
|
|
|
println!("Fetched all mainnet fallback services: {services:?}");
|
2022-12-02 23:41:50 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|