Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ impl BeaconNodeHttpClient {

/// Perform a HTTP GET request, returning `None` on a 404 error.
async fn get_opt<T: DeserializeOwned, U: IntoUrl>(&self, url: U) -> Result<Option<T>, Error> {
match self.get_response(url, |b| b).await.optional()? {
match self
.get_response(url, |b| b.accept(Accept::Json))
.await
.optional()?
{
Some(response) => Ok(Some(response.json().await?)),
None => Ok(None),
}
Expand All @@ -231,7 +235,7 @@ impl BeaconNodeHttpClient {
timeout: Duration,
) -> Result<Option<T>, Error> {
let opt_response = self
.get_response(url, |b| b.timeout(timeout))
.get_response(url, |b| b.timeout(timeout).accept(Accept::Json))
.await
.optional()?;
match opt_response {
Expand Down Expand Up @@ -982,16 +986,14 @@ impl BeaconNodeHttpClient {

/// `GET beacon/deposit_snapshot`
pub async fn get_deposit_snapshot(&self) -> Result<Option<types::DepositTreeSnapshot>, Error> {
use ssz::Decode;
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("beacon")
.push("deposit_snapshot");
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_deposit_snapshot)
.await?
.map(|bytes| DepositTreeSnapshot::from_ssz_bytes(&bytes).map_err(Error::InvalidSsz))
.transpose()
self.get_opt_with_timeout::<GenericResponse<_>, _>(path, self.timeouts.get_deposit_snapshot)
.await
.map(|opt| opt.map(|r| r.data))
}

/// `POST beacon/rewards/sync_committee`
Expand Down
2 changes: 2 additions & 0 deletions consensus/types/src/deposit_tree_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ impl From<&DepositTreeSnapshot> for FinalizedExecutionBlock {
pub struct DepositTreeSnapshot {
pub finalized: Vec<Hash256>,
pub deposit_root: Hash256,
#[serde(with = "serde_utils::quoted_u64")]
pub deposit_count: u64,
pub execution_block_hash: Hash256,
#[serde(with = "serde_utils::quoted_u64")]
pub execution_block_height: u64,
}

Expand Down