mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Pull Eth2Config during bootstrap
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use eth2_config::Eth2Config;
|
||||
use eth2_libp2p::{
|
||||
multiaddr::{Multiaddr, Protocol},
|
||||
Enr,
|
||||
@@ -74,6 +75,11 @@ impl Bootstrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the servers Eth2Config.
|
||||
pub fn eth2_config(&self) -> Result<Eth2Config, String> {
|
||||
get_eth2_config(self.url.clone()).map_err(|e| format!("Unable to get Eth2Config: {:?}", e))
|
||||
}
|
||||
|
||||
/// Returns the servers ENR address.
|
||||
pub fn enr(&self) -> Result<Enr, String> {
|
||||
get_enr(self.url.clone()).map_err(|e| format!("Unable to get ENR: {:?}", e))
|
||||
@@ -129,6 +135,19 @@ fn get_slots_per_epoch(mut url: Url) -> Result<Slot, Error> {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
fn get_eth2_config(mut url: Url) -> Result<Eth2Config, Error> {
|
||||
url.path_segments_mut()
|
||||
.map(|mut url| {
|
||||
url.push("spec").push("eth2_config");
|
||||
})
|
||||
.map_err(|_| Error::InvalidUrl)?;
|
||||
|
||||
reqwest::get(url)?
|
||||
.error_for_status()?
|
||||
.json()
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
fn get_finalized_slot(mut url: Url, slots_per_epoch: u64) -> Result<Slot, Error> {
|
||||
url.path_segments_mut()
|
||||
.map(|mut url| {
|
||||
|
||||
Reference in New Issue
Block a user