Skip to content

Commit 28ce703

Browse files
committed
Use JSON by default for Deposit Snapshot Sync
1 parent 2548be3 commit 28ce703

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

common/eth2/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ impl BeaconNodeHttpClient {
218218

219219
/// Perform a HTTP GET request, returning `None` on a 404 error.
220220
async fn get_opt<T: DeserializeOwned, U: IntoUrl>(&self, url: U) -> Result<Option<T>, Error> {
221-
match self.get_response(url, |b| b).await.optional()? {
221+
match self
222+
.get_response(url, |b| b.accept(Accept::Json))
223+
.await
224+
.optional()?
225+
{
222226
Some(response) => Ok(Some(response.json().await?)),
223227
None => Ok(None),
224228
}
@@ -982,16 +986,14 @@ impl BeaconNodeHttpClient {
982986

983987
/// `GET beacon/deposit_snapshot`
984988
pub async fn get_deposit_snapshot(&self) -> Result<Option<types::DepositTreeSnapshot>, Error> {
985-
use ssz::Decode;
986989
let mut path = self.eth_path(V1)?;
987990
path.path_segments_mut()
988991
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
989992
.push("beacon")
990993
.push("deposit_snapshot");
991-
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_deposit_snapshot)
992-
.await?
993-
.map(|bytes| DepositTreeSnapshot::from_ssz_bytes(&bytes).map_err(Error::InvalidSsz))
994-
.transpose()
994+
self.get_opt::<GenericResponse<_>, _>(path)
995+
.await
996+
.map(|opt| opt.map(|r| r.data))
995997
}
996998

997999
/// `POST beacon/rewards/sync_committee`

0 commit comments

Comments
 (0)