Skip to content

Commit

Permalink
chore(forrestrie): include previous related PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
suchapalaver committed Oct 21, 2024
1 parent 829c372 commit 8ea5efa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/forrestrie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ types.workspace = true
[dev-dependencies]
firehose-client = { path = "../firehose-client" }
insta.workspace = true
reqwest.workspace = true
reqwest = { workspace = true, features = ["json"] }
serde_json.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
12 changes: 5 additions & 7 deletions crates/forrestrie/examples/single_execution_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,19 @@ use types::{
const EXECUTION_BLOCK_NUMBER: u64 = 20759937;
/// This slot is the slot of the Beacon block that contains the execution block with [`EXECUTION_BLOCK_NUMBER`].
const BEACON_SLOT_NUMBER: u64 = 9968872; // <- 9968872 pairs with 20759937
/// The URL to fetch the head state of the Beacon chain.
const LIGHT_CLIENT_DATA_URL: &str =
"https://www.lightclientdata.org/eth/v2/debug/beacon/states/head";

#[tokio::main]
async fn main() {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get the head state of the Beacon chain from a Beacon API provider.
let state_handle = tokio::spawn(async move {
let url = "https://www.lightclientdata.org/eth/v2/debug/beacon/states/head".to_string();
let url = LIGHT_CLIENT_DATA_URL.to_string();
println!("Requesting head state ... (this can take a while!)");
let response = reqwest::get(url).await.unwrap();
let head_state: HeadState<MainnetEthSpec> = if response.status().is_success() {
let json_response: serde_json::Value = response.json().await.unwrap();
serde_json::from_value(json_response).unwrap()
} else {
panic!("Request failed with status: {}", response.status());
};
let head_state: HeadState<MainnetEthSpec> = response.json().await.unwrap();
head_state
});

Expand Down

0 comments on commit 8ea5efa

Please sign in to comment.