forked from eigerco/helios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkpoints.rs
42 lines (35 loc) · 1.71 KB
/
checkpoints.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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();
println!("Fetched latest goerli checkpoint: {goerli_checkpoint}");
// Fetch the latest mainnet checkpoint
let mainnet_checkpoint = cf
.fetch_latest_checkpoint(&networks::Network::MAINNET)
.await
.unwrap();
println!("Fetched latest mainnet checkpoint: {mainnet_checkpoint}");
// Let's get a list of all the fallback service endpoints for mainnet
let endpoints = cf.get_all_fallback_endpoints(&networks::Network::MAINNET);
println!("Fetched all mainnet fallback endpoints: {endpoints:?}");
// 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);
println!("Fetched all mainnet fallback services: {services:?}");
Ok(())
}