Implement liveness BeaconAPI (#4343)

## Issue Addressed

#4243

## Proposed Changes

- create a new endpoint for liveness/{endpoint}

## Additional Info
This is my first PR.
This commit is contained in:
Aoi Kurokawa
2023-07-31 01:53:03 +00:00
parent 071dd4cd9c
commit 85a3340d0e
4 changed files with 136 additions and 0 deletions

View File

@@ -1636,6 +1636,24 @@ impl BeaconNodeHttpClient {
.await
}
/// `POST validator/liveness/{epoch}`
pub async fn post_validator_liveness_epoch(
&self,
epoch: Epoch,
indices: Vec<u64>,
) -> Result<GenericResponse<Vec<StandardLivenessResponseData>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("validator")
.push("liveness")
.push(&epoch.to_string());
self.post_with_timeout_and_response(path, &indices, self.timeouts.liveness)
.await
}
/// `POST validator/duties/attester/{epoch}`
pub async fn post_validator_duties_attester(
&self,

View File

@@ -1225,6 +1225,13 @@ impl FromStr for Accept {
}
}
#[derive(PartialEq, Debug, Serialize, Deserialize)]
pub struct StandardLivenessResponseData {
#[serde(with = "serde_utils::quoted_u64")]
pub index: u64,
pub is_live: bool,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LivenessRequestData {
pub epoch: Epoch,