mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
Extended API
- Added a /beacon/validators function, to list all validators active in a particular epoch - Moved 'get_genesis_state' function, to align with router. - Added content-type for error responses - Tried adding a cache update call to fix issue getting validator duties (this is WIP)
This commit is contained in:
@@ -60,6 +60,18 @@ pub fn get_validator_duties<T: BeaconChainTypes + 'static>(req: Request<Body>) -
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let mut duties: Vec<ValidatorDuty> = Vec::new();
|
||||
|
||||
// Update the committee cache
|
||||
// TODO: Do we need to update the cache on the state, for the epoch which has been specified?
|
||||
beacon_chain
|
||||
.state_now()
|
||||
.map_err(|e| ApiError::ServerError(format!("Unable to get current BeaconState {:?}", e)))?
|
||||
.maybe_as_mut_ref()
|
||||
.ok_or(ApiError::ServerError(
|
||||
"Unable to get mutable BeaconState".into(),
|
||||
))?
|
||||
.build_committee_cache(relative_epoch, &beacon_chain.spec)
|
||||
.map_err(|e| ApiError::ServerError(format!("Unable to build state caches: {:?}", e)))?;
|
||||
|
||||
// Get a list of all validators for this epoch
|
||||
let validator_proposers: Vec<usize> = epoch
|
||||
.slot_iter(T::EthSpec::slots_per_epoch())
|
||||
@@ -67,6 +79,7 @@ pub fn get_validator_duties<T: BeaconChainTypes + 'static>(req: Request<Body>) -
|
||||
head_state
|
||||
.get_beacon_proposer_index(slot, relative_epoch, &beacon_chain.spec)
|
||||
.map_err(|e| {
|
||||
// TODO: why are we getting an uninitialized state error here???
|
||||
ApiError::ServerError(format!(
|
||||
"Unable to get proposer index for validator: {:?}",
|
||||
e
|
||||
|
||||
Reference in New Issue
Block a user