Skip to content

Commit

Permalink
Add beaconchain api key. (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSasaPrsic authored Aug 17, 2024
1 parent c8ed8aa commit 1e3815d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ ETH_PROOF_CACHE_MAXAGE=
SLOT_MAPPING_CACHE_MAXAGE=
HOST=
PORT=
BEACONCHAIN_API_KEY=
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct AppState {
avl_proof_cache_maxage: u32,
eth_proof_cache_maxage: u32,
slot_mapping_cache_maxage: u32,
beaconchain_api_key: String,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -387,6 +388,7 @@ async fn get_beacon_slot(
let resp = state
.request_client
.get(format!("{}/{}", state.beaconchain_base_url, slot))
.header("apikey", state.beaconchain_api_key.clone())
.send()
.await;

Expand Down Expand Up @@ -671,6 +673,7 @@ async fn main() {
.ok()
.and_then(|slot_mapping_response| slot_mapping_response.parse::<u32>().ok())
.unwrap_or(172800),
beaconchain_api_key: env::var("BEACONCHAIN_API_KEY").unwrap_or("".to_owned()),
});

let app = Router::new()
Expand Down

0 comments on commit 1e3815d

Please sign in to comment.